If you want to dump the JSON into a file/socket or whatever, then you should go with dump(). If you only need it as a string (for printing, parsing or whatever) then use dumps() (dump string)

As mentioned by Antti Haapala in this answer, there are some minor differences on the ensure_ascii behaviour. This is mostly due to how the underlying write() function works, being that it operates on chunks rather than the whole string. Check his answer for more details on that.

json.dump()

Serialize obj as a JSON formatted stream to fp (a .write()-supporting file-like object

If ensure_ascii is False, some chunks written to fp may be unicode instances

json.dumps()

Serialize obj to a JSON formatted str

If ensure_ascii is False, the result may contain non-ASCII characters and the return value may be a unicode instance

Answer from João Gonçalves on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-difference-between-json-dump-and-json-dumps
Difference between json.dump() and json.dumps() - Python - GeeksforGeeks
July 3, 2025 - It is a complete language-independent text format. To work with JSON data, Python has a built-in package called json. json.dumps() method can convert a Python object into a JSON string.
🌐
GeeksforGeeks
geeksforgeeks.org › python-difference-between-json-dump-and-json-dumps
Python – Difference between json.dump() and json.dumps() | GeeksforGeeks
April 28, 2025 - Note: For more information, refer to Working With JSON Data in Python · json.dumps() method can convert a Python object into a JSON string.
🌐
Educative
educative.io › answers › what-is-the-difference-between-jsonloads-and-jsondumps
What is the difference between json.loads() and json.dumps()?
In this Answer, we will discuss the difference between the json.loads() and the json.dumps(). The json.loads() takes in a string and returns a python object and the json.dumps() takes in a Python object and returns a JSON string.
🌐
GeeksforGeeks
geeksforgeeks.org › python › json-dump-in-python
json.dump() in Python - GeeksforGeeks
January 8, 2020 - Both json.dump() and json.dumps() are used to convert Python objects into JSON, but they differ in where the JSON output goes a file or a string.
Find elsewhere
🌐
Vitoshacademy
vitoshacademy.com › json-dump-vs-json-dumps-in-python
Json.dump vs json.dumps in Python – Useful code
sort_keys = True – sorting the beautiful JSON string · ensure_ascii · Python · The dump (without “S”) can also ensure ascii, indent and sort the keys and this is the reason why I am not going to demonstrate it. Still, continuing the code from above, we may produce a nice file named “RealDeal.txt” with two lines in it, using the following code: lines.py ·
🌐
PYnative
pynative.com › home › python › json › python json dump() and dumps() for json encoding
Python JSON dump() and dumps() for JSON Encoding
May 14, 2021 - The json module provides the following two methods to encode Python objects into JSON format. The json.dump() method (without “s” in “dump”) used to write Python serialized object as JSON formatted data into a file.
🌐
Python
docs.python.org › 3 › library › json.html
JSON encoder and decoder — Python 3.14.3 documentation
Serialize obj to a JSON formatted str using this conversion table. The arguments have the same meaning as in dump().
🌐
Leapcell
leapcell.io › blog › understanding-json-dumps-in-python
Understanding `json.dumps()` in Python | Leapcell
July 25, 2025 - The “s” in dumps stands for “dump string.” Unlike json.dump() which writes JSON data directly to a file, dumps() returns the JSON data as a string, making it useful when you need to store or transmit JSON data.
🌐
Reddit
reddit.com › r/learnpython › why json.dump() and .load() are really needed?
r/learnpython on Reddit: Why json.dump() and .load() are really needed?
October 15, 2020 -

Hi, hope everyone is well.

Just nearing the basics end of PCC book, I'm at saving user's data now. What exactly is the reason, when storing simple data, to use json.dump() or load(), instead of just saving and then reading it from simple text file?

I just can't place it in my head why do I really need it and it always makes it more difficult for me to learn if that's the case.

Thank you all in advance.

Top answer
1 of 8
6
JSON data in python is essentially a dictionary (at least they are interchangeable, there are some minor differences with the formatting). Have you tried saving a dictionary to a simple text file? my_data = { 'a': [1, 2, 3], 'b': {'foo': 'bar', 'baz': [4, 5, 6]} } with open('test_file.txt', 'w') as file: file.write(my_data) This is not possible because Python expects a string that it can write to a file. It doesn't know how to turn a dictionary into something it can write to a file. But, maybe you then do this instead: my_data = { "a": [1, 2, 3], "b": {"foo": "bar", "baz": [4, 5, 6]} } with open('test_file.txt', 'w') as file: # cast my_data to a string first file.write(str(my_data)) And it works. But what if you want to read that file? with open('test_file.txt', 'r') as file: read_data = file.read() Now you have a problem, because your output is this string: "{'a': [1, 2, 3], 'b': {'foo': 'bar', 'baz': [4, 5, 6]}}" How do you convert a string into a dictionary? This here doesn't work: with open('test_file.txt', 'r') as file: read_data = dict(file.read()) Python by itself does not know how to convert a string into a dictionary. For that you need JSON. Also it makes sure that you meet all the conventions of the JSON format so that you can exchange data between different languages (e.g. from Python to JavaScript). The other thing is, if you have a .txt file, how would anybody know that this file contains a data structure without opening the file? If the file extension says "JSON" everybody knows how to interpret the data. Same with .XML, .HTML etc.
2 of 8
3
How would you structure the text file so that you can load the data later?
🌐
Towards Data Science
towardsdatascience.com › home › latest › you must know python json dumps, but maybe not all aspects
You Must Know Python JSON Dumps, But Maybe Not All Aspects | Towards Data Science
January 20, 2025 - Now, if we try to output this dictionary, Python will display ... because there is a circular reference. If we try to dump the JSON string from such a dictionary, the circular reference will be detected and throw an error.
🌐
Plain English
python.plainenglish.io › json-dumps-vs-json-dump-vs-json-loads-vs-json-load-in-python-99040c885c90
json.dumps VS json.dump VS json.loads VS json.load in Python | by Liu Zuo Lin | Python in Plain English
August 10, 2023 - json.dumps VS json.dump VS json.loads VS json.load in Python # This has confused me for a long time If you’re new to JSON, JSON stands for JavaScript Object Notation. string = '{"apple": 4 …
🌐
Medium
medium.com › data-science › you-must-know-python-json-dumps-but-maybe-not-all-aspects-fa8d98a76aa0
You Must Know Python JSON Dumps, But Maybe Not All Aspects | by Christopher Tao | TDS Archive | Medium
December 6, 2021 - Python has built-in support to JSON documents, by its “json” module. I bet most of us have used it, and some of us have used it a lot. We know that we can use the json.dumps() method to easily convert a Python dictionary object into a JSON string.
🌐
Proxy-Seller
proxy-seller.com › blog › how-to-work-with-json-dump-in-python-ultimate-guide
How to Use json.dump() in Python: Useful Guide
The json module is part of Python’s ... of the script is sufficient. The json.dump() function supports serialization only of objects that can be represented in JSON format....
🌐
Python Forum
python-forum.io › thread-40905.html
JSON Dump and JSON Load
I apologize, the insert code snippet button isn't working. I am having an issue dumping to json and then reading back in. When I read it back in correctly. In the screenshot you can see visual studio indicating the object is slightly different and w...
🌐
GeeksforGeeks
geeksforgeeks.org › python › json-dumps-in-python
json.dumps() in Python - GeeksforGeeks
The json.dumps() function in Python converts a Python object (such as a dictionary or list) into a JSON-formatted string.
Published   March 3, 2020