JSON tools

JSON Formatter and Beautifier

Pretty-print or minify JSON as you type, pinpoint every error by line and column, and repair almost-JSON in one click.

  • Free foreverNo trial, no paywall, no usage limits.
  • No sign-upOpen the page and start. We never ask for an email to use a tool.
  • PrivateEverything runs in your browser. Your input is never uploaded or stored on our servers.
  • Works offlineOnce the page has loaded, the tool keeps working without a connection.
Pretty-print with line breaks and indentation, for reading and code review.Strip all whitespace for the smallest payload: API bodies, config values, URLs.
Two spaces: the default in JavaScript, Prettier and most style guides.Four spaces: common in Python and C# projects.One tab per level, so each reader picks their own width.
Sort object keys A to Z at every level (arrays keep their order). Makes two documents easy to compare and diffs stable.
RFC 8259 JSON, exactly what JSON.parse and APIs accept. Comments and trailing commas are errors.JSONC, as in tsconfig.json and VS Code settings: allows // and /* */ comments and trailing commas.
Turn almost-JSON into valid JSON: strips comments and trailing commas, converts single quotes, quotes keys, fixes True/None/NaN, closes brackets. Undo is one click.

Input JSON

Paste JSON, drop a .json file onto the editor, or open one. Files up to 5 MB are read locally and never uploaded.
Clear

Formatted JSON

The formatted text, ready to copy.Browse the structure: expand and collapse nodes, see item counts, copy any value's path.
Use output as inputCopyDownload formatted.json
Paste JSON, drop a file or load the example. Everything runs in your browser.

Need this built into your own API or pipeline? Talk to our team

Quick answer

A JSON formatter, or beautifier, re-indents JSON so its structure is easy to read without changing the data. Paste or drop JSON into Playxoft's free JSON Formatter and it is formatted as you type with 2 spaces, 4 spaces or tabs. Errors show their exact line and column with a fix, Repair turns JSONC or JavaScript-style objects into valid JSON, and Minify strips whitespace for the smallest payload.

  • Format and minify
  • 2, 4 or tab indent
  • Line and column errors
  • One-click repair
  • Deep key sorting
  • Collapsible tree view
  • Exact big numbers
  • Works offline

How to use the JSON Formatter

  1. 1Paste JSON into Input JSON, drop a .json file onto the editor, or click Open.
  2. 2Choose Format and an Indent (2 or 4 spaces, or Tab), or choose Minify for a single line.
  3. 3Turn on Sort keys for a stable alphabetical key order at every level.
  4. 4If the status bar shows an error, click Go to error and fix it, or press Repair to fix common mistakes automatically.
  5. 5Copy or download the result, or switch the output to Tree to explore the structure.

What does a JSON formatter do?

JSON ignores whitespace between tokens, so {"a":1} and the same object spread over three lines are identical data. A formatter (also called a beautifier or pretty-printer) rewrites only that whitespace: one member per line and each level indented, so you can see the structure at a glance. Minifying does the opposite and removes every optional space and line break.

Formatting never changes the data. This tool prints from a lossless syntax tree rather than through JSON.parse and JSON.stringify, so:

  • numbers keep their exact spelling: 1.50 stays 1.50, and 12345678901234567890 keeps all 20 digits;
  • string escapes such as \u00e9 stay exactly as you wrote them;
  • duplicate keys are kept and flagged, instead of silently collapsing to the last one;
  • key order is preserved unless you turn on Sort keys.

The grammar it checks is RFC 8259, the current JSON standard, which matches ECMA-404 in substance.

Strict JSON vs JSONC vs JSON5: what's the difference?

Plenty of files that look like JSON aren't strict JSON. Three dialects cover almost everything you will paste:

FeatureJSON (RFC 8259)JSONCJSON5
CommentsNoYesYes
Trailing commasNoParser-dependent (tsconfig accepts them)Yes
Single-quoted stringsNoNoYes
Unquoted keysNoNoYes
NaN, Infinity, hex numbersNoNoYes
Typical homeAPIs, JSON.parse, databasestsconfig.json, VS Code settingsHand-edited config files

Strict mode validates plain JSON: use it for anything a program will parse. Lenient mode accepts JSONC and keeps your comments when it re-indents.

To get strict JSON out of JSONC, JSON5 or a JavaScript object literal, click Repair. It strips comments and trailing commas, converts single quotes, quotes bare keys, replaces NaN, undefined and Python's True, False and None, unwraps Markdown code fences and JSONP callbacks, and lists every change it made. One click on Undo repair puts your original back.

What are the most common JSON errors and how do I fix them?

ErrorLooks likeFix
Trailing comma[1, 2, 3,]Delete the comma after the last item
Single quotes{'name': 'Ada'}Use double quotes: {"name": "Ada"}
Unquoted key{name: "Ada"}Quote every key: {"name": "Ada"}
Comment// productionRemove it, or use Lenient (JSONC) mode
NaN or Infinity{"ratio": NaN}Use null or a string
Leading zero{"zip": 02134}Store it as a string: "02134"
Missing comma{"a": 1 "b": 2}Put a comma between members
Line break inside a stringA string split over two linesEscape the break as \n
Python literalsTrue, NoneUse true and null

The status bar under the editor names the first problem with its line and column, explains the fix, and Go to error puts the cursor right on it while the line is highlighted in the gutter. To see every error in a document at once, use the JSON Validator.

Why do big numbers change after JSON.parse?

JavaScript stores every number as a 64-bit float, which holds integers exactly only up to Number.MAX_SAFE_INTEGER: 2^53 − 1, or 9,007,199,254,740,991. Anything larger is rounded without warning:

JSON.parse('{"id": 9007199254740993}').id   // 9007199254740992

That is why large identifiers, such as snowflake IDs and some payment references, should travel as strings. Twitter's API famously sent every ID twice, as id and id_str, for exactly this reason.

This formatter never converts values to JavaScript numbers, so it keeps the digits you pasted and adds a warning for each unsafe integer, with its path. Other runtimes differ: Python's json module reads big integers exactly, and Go keeps them if you decode with json.Decoder.UseNumber().

How do I format JSON in code?

Every mainstream language has a built-in pretty-printer, and jq covers the shell:

// JavaScript / TypeScript
JSON.stringify(data, null, 2);      // 2-space indent
JSON.stringify(data);               // minified

# Python
json.dumps(data, indent=2, ensure_ascii=False, sort_keys=True)
python -m json.tool input.json      # from the shell

# jq
jq . input.json                     # pretty-print
jq -S . input.json                  # sort keys
jq -c . input.json                  # minify

// Go
out, err := json.MarshalIndent(data, "", "  ")

Sorting keys (sort_keys=True, jq -S, or Sort keys here) gives a canonical order, which keeps diffs small and makes two documents easy to compare. To see exactly what changed between two versions, the JSON Diff tool compares them value by value, and the JSON to TypeScript generator turns a formatted response into types.

Frequently asked questions

No. Only whitespace changes. Keys stay in their original order unless you turn on Sort keys, and numbers and string escapes are printed exactly as you wrote them, including integers too large for JavaScript.
Two spaces is the most common choice and the default in JavaScript tooling and Prettier. Four spaces is common in Python and C# projects, and tabs let each reader choose their own width. Follow whatever your repository already uses.
Yes. Switch to Lenient mode and the formatter accepts JSONC, the dialect used by tsconfig.json and VS Code settings, and keeps your comments in place. If you need strict JSON instead, click Repair to remove them.
JavaScript object literals allow single quotes, unquoted keys, trailing commas, comments and values like undefined. JSON allows none of these. Click Repair to convert a JavaScript object into valid JSON automatically.
Files up to 5 MB open directly, and larger pasted text works too. Typing stays responsive because formatting runs in the background, and the tree view shows the first few thousand rows to stay fast.
Formatting adds line breaks and indentation so people can read the JSON. Minifying removes all optional whitespace so the payload is as small as possible for networks and storage. Both represent exactly the same data.
No. Parsing, formatting and repair all run in your browser. Nothing you paste or open is sent to a server, logged or stored, so it is safe for API keys, tokens and production data.

Last updated by the Playxoft engineering team.

From the engineers who built this tool

Fighting messy data every day?

When payloads, schemas and integrations keep breaking, the fix is usually upstream. We design typed APIs and backends that stay clean as you grow. Tell us what you are building and we will suggest the simplest architecture that fits.