indent
A positive integer indent inserts that many spaces per level. The documentation demonstrates indent=4 for pretty printing.
4compact_separators
Use separators=(',', ':') to eliminate separator whitespace for compact output.
[",",":"]cli
The json.tool command validates and pretty-prints JSON from the shell. Invalid unquoted property names produce an error.
"python -m json.tool"framed
JSON is not a framed protocol. Repeated dump calls to the same file produce an invalid JSON file.
falseTry the example
import json
record = {"name": "sample", "enabled": True}
print(json.dumps(record, indent=4))
print(json.dumps(record, separators=(",", ":")))Formatting is not a signature or a guarantee that two independently serialized documents have identical bytes. Compare the values you need, or define a separate byte-level contract.
Source and reuse
- Original
- Python 3.13.0: json encoder and decoder
- Version / observed
- CPython v3.13.0 / 2026-11-24T04:53:54.630820+00:00
- Use conditions
- PSF License Version 2
Copyright (c) 2001-2024 Python Software Foundation; All Rights Reserved
Full license text - SHA256
- 6533f6d5be67f903194ba4b92335d079552edb69c4c8fd45d6215de60358dd8e
The hash identifies the archived source bytes retrieved from the version tag, not a publisher-issued signature. These are condensed notes with newly written examples, not a verbatim replacement for the manual.
Archived source textInspect the complete public JSON
{
"schema": "llmsdocs-editorial-v1",
"id": "format",
"language": "en",
"revision": 1,
"edition": "2026-11-24",
"kind": "editorial",
"title": "Format a document for inspection",
"intro": "Readable output helps a reviewer inspect a document. Compact output changes whitespace, not the purpose of the data.",
"html_url": "https://llmsdocs.com/en/manual/format",
"json_url": "https://llmsdocs.com/en/manual/format.json",
"source": {
"id": "python-json-313",
"title": "Python 3.13.0: json encoder and decoder",
"url": "https://github.com/python/cpython/blob/v3.13.0/Doc/library/json.rst",
"version": "CPython v3.13.0",
"observed_at": "2026-11-24T04:53:54.630820+00:00",
"sha256": "6533f6d5be67f903194ba4b92335d079552edb69c4c8fd45d6215de60358dd8e",
"license": "PSF License Version 2",
"license_url": "https://github.com/python/cpython/blob/v3.13.0/LICENSE",
"copyright": "Copyright (c) 2001-2024 Python Software Foundation; All Rights Reserved",
"snapshot": "/manual-source/json.rst",
"license_snapshot": "/manual-source/LICENSE.txt"
},
"changes": "The source was condensed into topic notes. Examples are newly written; Korean notes are translations.",
"disclosure": "AI-assisted editorial notes, not official Python documentation or customer submissions.",
"facts": [
{
"id": "format-1",
"key": "indent",
"value": 4,
"text": "A positive integer indent inserts that many spaces per level. The documentation demonstrates indent=4 for pretty printing.",
"source_id": "python-json-313",
"source_lines": "54-61, 179-184"
},
{
"id": "format-2",
"key": "compact_separators",
"value": [
",",
":"
],
"text": "Use separators=(',', ':') to eliminate separator whitespace for compact output.",
"source_id": "python-json-313",
"source_lines": "189-192"
},
{
"id": "format-3",
"key": "cli",
"value": "python -m json.tool",
"text": "The json.tool command validates and pretty-prints JSON from the shell. Invalid unquoted property names produce an error.",
"source_id": "python-json-313",
"source_lines": "119-128"
},
{
"id": "format-4",
"key": "framed",
"value": false,
"text": "JSON is not a framed protocol. Repeated dump calls to the same file produce an invalid JSON file.",
"source_id": "python-json-313",
"source_lines": "212-216"
}
],
"example": "import json\nrecord = {\"name\": \"sample\", \"enabled\": True}\nprint(json.dumps(record, indent=4))\nprint(json.dumps(record, separators=(\",\", \":\")))",
"editorial_note": "Formatting is not a signature or a guarantee that two independently serialized documents have identical bytes. Compare the values you need, or define a separate byte-level contract."
}The source was condensed into topic notes. Examples are newly written; Korean notes are translations.