A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/python/python-convert-json-to-string/ below:

Convert JSON to string - Python

Convert JSON to string - Python

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: 

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:



RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4