You should use the built-in json module, which was designed explicitly for this task:

>>> import json
>>> data = '''
... {
...   "abc": null,
...   "def": 9
... }
... '''
>>> json.loads(data)
{'def': 9, 'abc': None}
>>> type(json.loads(data))
<class 'dict'>
>>>

By the way, you should use this method even if your JSON data contains no null values. While it may work (sometimes), ast.literal_eval was designed to evaluate Python code that is represented as a string. It is simply the wrong tool to work with JSON data.

Answer from user2555451 on Stack Overflow
🌐
Python
bugs.python.org › issue6566
Issue 6566: json.dumps converts None to "null" (not null) - Python tracker
July 24, 2009 - This issue tracker has been migrated to GitHub, and is currently read-only. For more information, see the GitHub FAQs in the Python's Developer Guide · This issue has been migrated to GitHub: https://github.com/python/cpython/issues/50815
Discussions

Help removing 'null' from json output
Post the code More on reddit.com
🌐 r/learnpython
22
1
July 16, 2020
Inconsistent JSON serialization of None keys ("None" instead of "null")
Initial Checks I confirm that I'm using Pydantic V2 Description During migration from v1 to v2 we discovered a change of behavior when serializing None keys in a dictionary to JSON. Since non-s... More on github.com
🌐 github.com
3
December 25, 2023
Working around JSON null values in Python - Stack Overflow
I have a json file where null means no value. I am trying to read from another field when the first value I am looking for is found to be null. But for the life of me I cannot figure out the syntax... More on stackoverflow.com
🌐 stackoverflow.com
Dealing with json null in python - Stack Overflow
I would like to ask if there is ... there is a way to transform them into None so that python can deal with them or delete the dictionaries in the list above that contain null values from the beginning using maybe a json method.... More on stackoverflow.com
🌐 stackoverflow.com
🌐
JSON Schema
json-schema.org › understanding-json-schema › reference › null
JSON Schema - null
When a schema specifies a type of null, it has only one acceptable value: null. It's important to remember that in JSON, null isn't equivalent to something being absent. See Required Properties for an example. ... In Python, null is analogous to None.
🌐
Appdividend
appdividend.com › handle-json-null-in-python
How to Handle JSON NULL in Python
April 16, 2025 - To handle the JSON NULL in Python, use the json.loads() method. The loads() method returns the null equivalent of None.
🌐
GeeksforGeeks
geeksforgeeks.org › python › check-if-json-object-has-empty-value-in-python
Check if Json Object has Empty Value in Python - GeeksforGeeks
July 23, 2025 - In this example, below code imports, the `json` module, processes a JSON string (`,`) with key-value pairs, and converts it into a Python dictionary (`parsed_json`). It then iterates through the dictionary, identifying and printing keys linked to empty values like an empty string or null.
Find elsewhere
🌐
Python Forum
python-forum.io › thread-10860.html
Replace null values in Json file
Hi all!! i am new in forum so i have very much to read! I have one problem with some code in python. I am trying to replace None values in Json file to 'vacio' values. My example of read file is: data = [] for reng in open('con_error.json', 'r'): ...
🌐
Reddit
reddit.com › r/learnpython › help removing 'null' from json output
r/learnpython on Reddit: Help removing 'null' from json output
July 16, 2020 -

I'm writing a program that pulls its data from excel, and then outputs a long block of json code. However, occasionally the cells will be empty, and so the json code displays null. How can I remove the null outputs from my json so that it only displays the cells that currently have a value?

🌐
GitHub
github.com › pydantic › pydantic › issues › 8438
Inconsistent JSON serialization of None keys ("None" instead of "null") · Issue #8438 · pydantic/pydantic
December 25, 2023 - Since non-string keys are invalid in JSON, both V1 and Python's json.dumps opt to serialize None to "null". This makes a lot of sense considering that JS's deserialization does translate "null" to a regular null (JSON.parse('{"null": 123}') # => {null: 123}).
Author   Saare
🌐
Like Geeks
likegeeks.com › home › python › how to remove null values from json in python
How To Remove Null Values from JSON in Python
January 29, 2024 - In this step, the comprehension iterates over each key-value pair in the dictionary, including them only if the value is not None. ... data_dict = {'customer_id': 12345, 'name': 'Jordan', 'email': None, 'phone': '555-1234', 'address': None} To remove null values by iterating and deleting, you can do the following:
🌐
Databricks
kb.databricks.com › notebooks › json-reader-parses-value-as-null
JSON reader parses values as null - Databricks
May 16, 2022 - Because the JSON parser does not allow empty strings in Spark 3.0 and above, a null value is returned as output. Set the Spark config (AWS | Azure | GCP) value spark.sql.legacy.json.allowEmptyString.enabled to True. This configures the Spark 3.0 JSON parser to allow empty strings. You can set this configuration at the cluster level or the notebook level. %python spark.conf.set("spark.sql.legacy.json.allowEmptyString.enabled", True) jsontest1 = spark.read.option("inferSchema","true").json("dbfs:/tmp/json/parse_test.txt") display(jsontest1) Cannot use IAM roles with table ACL ·
🌐
Google Groups
groups.google.com › g › jsonschema › c › mD6GDca4zN8
How to allow None (null) for fields in JSON Schema?
If you also want to allow null values for fb_id, you can set its schema to {"type": ["string", "null"]}  ·  · -- You received this message because you are subscribed to the Google Groups "jsonschema - An implementation of JSON Schema for Python" group.
🌐
Stack Overflow
stackoverflow.com › questions › 76864574 › working-around-json-null-values-in-python
Working around JSON null values in Python - Stack Overflow
import json import urllib.request,urllib.parse,urllib.error fh=urllib.request.urlopen('http://mrdata.usgs.gov/geology/state/json/IAXs;0') info=json.load(fh) if info['age'][0]['min_epoch'] == None: GEO_AGE = 2 or info['age'][0]['cmax_age'] else: GEO_AGE = 1 or info['age'][0]['min_epoch'] print('AGE: ', GEO_AGE)
🌐
GitHub
github.com › samuelcolvin › rtoml › issues › 23
Conversion of None to "null" string inconsistency · Issue #23 · samuelcolvin/rtoml
May 25, 2021 - "null" strings should be converted to None in python, or · fields with value "null" should not be imported at all. Conversely, for dumping None values: convert to null (without the quotation marks) -- representing a json null value · do not dump fields with value None at all ·
Published   May 25, 2021
Author   himbeles
🌐
Tutorial Reference
tutorialreference.com › python › examples › faq › python-how-to-convert-json-null-to-none
How to Convert Between JSON null and Python None | Tutorial Reference
Python: In Python, None can be a dictionary key. json.dumps(): When serializing to JSON, json.dumps() converts the None key to the string "null".