The difference is that json.dumps applies some minor pretty-printing by default but JSON.stringify does not.

To remove all whitespace, like JSON.stringify, you need to specify the separators.

json_mylist = json.dumps(mylist, separators=(',', ':'))
Answer from Mike Cluck on Stack Overflow
🌐
Reddit
reddit.com › r/learnpython › is there a python equivivalent of javascript's json.stringify() ?
r/learnpython on Reddit: Is there a Python equivivalent of JavaScript's JSON.stringify() ?
February 25, 2015 -

Long story short, is I have a wrapper over an API that pulls in a JSON from a rest call. I use json.loads() to return the response in my Python wrapper. I then use the response to make a REST call using POST method.

My problem is that I'm getting true, false, and none values converted to True, False, and None. When I make my second REST call I need them to be in the form of 'true', 'false, and 'none'. Basically, I want to preserve my string, float, and integers while converted these other types to strings.

Any ideas?

Discussions

python/aws_cdk.aws_secretsmanager: JSON.stringify in Python example
Describe the issue Small thing, but a bit of JS seems to have snuck into this Python example. Should probably be json.dumps rather than JSON.stringify. # Templated secret with username and password fields templated_secret = secretsmanage... More on github.com
🌐 github.com
9
April 4, 2023
How we made JSON.stringify more than twice as fast
Sooner or later is seems like everyone gets the idea of reducing event loop stalls in their NodeJS code by trying to offload it to another thread, only to discover they’ve tripled the CPU load in the main thread · I’ve seen people stringify arrays one entry at a time. More on news.ycombinator.com
🌐 news.ycombinator.com
168
458
August 11, 2025
🌐
W3Schools
w3schools.com › PYTHON › python_json.asp
Python JSON
JSON is text, written with JavaScript object notation. Python has a built-in package called json, which can be used to work with JSON data.
🌐
Python
docs.python.org › 3 › library › json.html
json — JSON encoder and decoder
2 weeks ago - If the data being deserialized is not a valid JSON document, a JSONDecodeError will be raised. Changed in version 3.6: All parameters are now keyword-only. ... Return the Python representation of s (a str instance containing a JSON document).
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-convert-json-to-string
Convert JSON to string - Python - GeeksforGeeks
July 12, 2025 - Let's see how to convert JSON to String. This code creates a Python dictionary and converts it into a JSON string using json.dumps().
🌐
Real Python
realpython.com › python-json
Working With JSON Data in Python – Real Python
August 20, 2025 - Learn how to work with JSON data in Python using the json module. Convert, read, write, and validate JSON files and handle JSON data for APIs and storage.
Find elsewhere
🌐
freeCodeCamp
freecodecamp.org › news › python-json-how-to-convert-a-string-to-json
Python JSON – How to Convert a String to JSON
November 9, 2021 - In this tutorial you'll learn the basics of JSON – what it is, where it is most commonly used, and its syntax. You'll also see how to convert a string to JSON in Python. Let's get started! What is JSON? JSON stands for JavaScript Object Notation. It...
🌐
GitHub
github.com › aws › aws-cdk › issues › 24931
python/aws_cdk.aws_secretsmanager: JSON.stringify in Python example · Issue #24931 · aws/aws-cdk
April 4, 2023 - # Templated secret with username and password fields templated_secret = secretsmanager.Secret(self, "TemplatedSecret", generate_secret_string=secretsmanager.SecretStringGenerator( secret_string_template=JSON.stringify({"username": "postgres"}), generate_string_key="password" ) ) https://docs.aws.amazon.com/cdk/api/v2/python/aws_cdk.aws_secretsmanager/README.html
Author   petertaylor3
🌐
Hacker News
news.ycombinator.com › item
TIL, thanks. But uh, I expected `JSON.stringify` to throw ...
December 26, 2023 - I also think the automatic conversion of a `Date` to a string is a bad thing, which again is prohibited in Python · But I think in the case of JSON.stringify it’s more about use case. 99% of the time, users of this method are taking some data and serialising it to a JSON compliant form to ...
🌐
DigitalOcean
digitalocean.com › community › tutorials › python-pretty-print-json
How to Pretty Print JSON in Python | DigitalOcean
September 16, 2025 - Control your JSON output’s compactness and character encoding with the separators and ensure_ascii parameters. Serialize custom Python objects that are not natively supported by creating a JSONEncoder subclass or by passing a handler function to the default parameter.
🌐
DataCamp
datacamp.com › tutorial › json-data-python
Python JSON Data: A Guide With Examples | DataCamp
December 3, 2024 - Here are some common functions from json library that are used for serialization and deserialization. This function is used to serialize a Python object into a JSON string. The dumps() function takes a single argument, the Python object, and returns a JSON string.
🌐
Spark By {Examples}
sparkbyexamples.com › home › python › convert json object to string in python
Convert JSON Object to String in Python - Spark By {Examples}
May 21, 2024 - The json.dumps() method is available in the json module which allows you to convert a python object into a json string.
🌐
W3Schools
w3schools.com › js › js_json_stringify.asp
JSON.stringify()
You can convert any JavaScript datatype into a string with JSON.stringify().
🌐
JSON Formatter
jsonformatter.org › json-stringify-online
JSON Stringify Online using JSON.Stringify()
JSON Stringify Online helps convert string value to JSON String using JSON.Stringify().
🌐
JSONLint
jsonlint.com
JSONLint - The JSON Validator
JSON Stringify · JSON Diff · JSON Schema Validator · JSON Path Query · Mastering JSON Format: Advantages, Best Practices and Comparison with Other Data Formats · Common JSON Mistakes and How to Avoid Them · Mastering JSON in JavaScript: Comprehensive Examples and Techniques ·
🌐
Zyte
zyte.com › home › blog › json parsing with python [practical guide]
JSON Parsing with Python [Practical Guide]
July 6, 2023 - In this guide, we’ll explore the syntax and data types of JSON, as well as the Python libraries and methods used for parsing JSON data, including more advanced options like JMESPath and ChompJS, which are very useful for web scraping data.
🌐
Json Parser Online
json.parser.online.fr
Json Parser Online
Analyze your JSON string as you type with an online Javascript parser, featuring tree view and syntax highlighting. Processing is done locally: no data send to server.
🌐
Hacker News
news.ycombinator.com › item
How we made JSON.stringify more than twice as fast | Hacker News
August 11, 2025 - Sooner or later is seems like everyone gets the idea of reducing event loop stalls in their NodeJS code by trying to offload it to another thread, only to discover they’ve tripled the CPU load in the main thread · I’ve seen people stringify arrays one entry at a time.
🌐
JSON Formatter
jsonformatter.org › json-parser
JSON Parser Online to parse JSON
JSON Example with all data types including JSON Array. Python Pretty Print JSON · Read JSON File Using Python · Validate JSON using PHP · Python Load Json From File · JSON.Parse() is javascript method for parsing JSON which converts to JavaScript objects.