Convert JSON to string Python (original) (raw)

Last Updated : 12 Jul, 2025

Data is transmitted across platforms using API calls. Data is mostly retrieved in JSON format. We can convert the obtained JSON data into String data for the ease of storing and working with it. Python provides built-in support for working with JSON through the json module. We can convert JSON data into a string using the **json.dumps() method.

Let's see how to convert JSON to String.

Json to String on dummy data using "json.dumps"

This code creates a Python dictionary and converts it into a JSON string using json.dumps(). The result is printed along with its type, confirming that the output is now a string.

Python `

import json

create a sample json

a = {"name" : "GeeksforGeeks", "Topic" : "Json to String", "Method": 1}

y = json.dumps(a)

print(y) print(type(y))

`

**Output:

jsonToString

**Explanation:

Json to String using an API using requests and "json.dumps"

This code makes a GET request to a dummy API to fetch employee data, converts the JSON response into a Python dictionary using json.loads(), and then converts it back into a JSON string using json.dumps(). The string is printed along with its type.

Python `

import json import requests

Get dummy data using an API

res = requests.get("http://dummy.restapiexample.com/api/v1/employees")

Convert data to dict

d = json.loads(res.text)

Convert dict to string

d = json.dumps(d)

print(d) print(type(d))

`

**Output:

**Explanation: