Skip to content

JSON formatter

Paste JSON to format it, check it or make it one line.

0 characters · 0 lines

0 characters · 0 lines

Your files are open only in this tab. Nothing is uploaded.

Convert JSON with: JSON to YAML JSON to CSV

How to use JSON formatter

  1. Paste or open your JSON input. Paste text into the JSON box, select Try an example, or drag and drop a .json file up to 20 MB via Open file.
  2. Select a mode, indent width, or key order. Pick Format, Minify, or Tree under Mode to pretty print JSON with 2 spaces, 4 spaces, or tabs, and check Sort keys A–Z to order keys alphabetically.
  3. Resolve syntax or duplicate-key warnings. When a parse alert appears, read the plain-English fix hint and select Go to line to highlight the exact line and column in the editor.
  4. Copy or download the output. Select Copy to place the result on your clipboard, or select Download to save data.json (or data.min.json in Minify mode) to your device.

Everything runs in this browser tab. Nothing you paste or open is uploaded or logged, so it's safe for keys, tokens and private data.

Formatting, minifying, and inspecting JSON locally

REST responses, webhook deliveries, log records, and bundler manifests often arrive as a single dense line of text with optional whitespace stripped. Pasting that raw payload into this JSON formatter lets you pretty print JSON with 2 spaces, 4 spaces, or tabs, validate every token, or collapse it back to one line.

Choosing between Format, Minify, and Tree mode

Under the ECMA-404 JSON Data Interchange Syntax Standard, spaces, horizontal tabs, line feeds, and carriage returns outside quoted strings carry zero semantic weight. Format mode indents nested objects and arrays cleanly (data.json), whereas Minify strips insignificant whitespace (data.min.json).

Switching Mode to Tree renders an interactive collapsible hierarchy so you can expand deep API objects without scrolling through thousands of raw lines. Both Format and Tree respect your selected Indent width and Sort keys A–Z toggle.

Keeping bearer tokens and API payloads in your tab

Developers routinely inspect production payloads containing bearer tokens, session cookies, customer PII, and internal microservice URLs. Because every parse and serialization step executes inside your current tab, you can format and validate JSON without uploading confidential strings anywhere.

When an authorization header still contains a compact three-part token string, decode Base64URL payloads inside a JWT locally before inspecting the JSON claims.

Strict RFC 8259 syntax rules and parse error fixes

Reliable cross-language serialization requires strict grammar compliance. Under the IETF RFC 8259 JSON Data Interchange Standard, a valid document may contain only objects, arrays, double-quoted Unicode strings, decimal numbers, true, false, and null, which explains why JSONC comments, single quotes, and unquoted keys fail in Go, Rust, Python, and PostgreSQL parsers.

When an unexpected token or trailing comma breaks parsing, the error banner converts character offsets into 1-based line and column coordinates with a Go to line button. Teams working with Kubernetes or GitHub Actions manifests can also generate strict JSON from YAML manifests before validating.

Broken input pattern Why strict parsers reject it Built-in hint message Corrected JSON
{"a": 1,} Trailing comma before closing brace Remove the comma after the last item. {"a": 1}
{'a': 'ok'} Single quotes instead of double quotes JSON needs double quotes, not single quotes. {"a": "ok"}
{a: 1} Unquoted object property name Keys need double quotes around them. {"a": 1}
{"a": 1 "b": 2} Missing comma between members Is a comma missing before this? {"a": 1, "b": 2}
// config JavaScript or JSONC comment syntax JSON doesn't allow comments. Remove comment

How does this formatter preserve 64-bit IDs and catch duplicates?

After validating strict JSON grammar, this parser scans numeric tokens outside quoted strings and replaces integers exceeding 53 bits with exact BigInt values, while simultaneously walking object scopes to flag duplicate keys. Standard browser JSON.parse() rounds large 64-bit identifiers and silently overwrites repeated property names.

Avoiding IEEE 754 rounding with BigInt tokens

Per the MDN Number.MAX_SAFE_INTEGER Documentation, JavaScript Number values rely on IEEE 754 double-precision floats, which cap exact integer representation at 9,007,199,254,740,991 (2^53 - 1). Formatting a 19-digit Snowflake ID or 64-bit database primary key with naive JSON.parse() corrupts the trailing digits.

By isolating integer literals of 16 or more digits that fail Number.isSafeInteger(), the formatter preserves exact digits across Format, Minify, Sort keys A–Z, and Tree views. When exporting tabular records for spreadsheets, you can use the JSON to CSV flattener with those 64-bit IDs intact.

Flagging duplicate object keys before silent overwrites

RFC 8259 recommends unique member names inside every JSON object, yet different backend languages resolve repeated keys inconsistently (some keep the first value, while JavaScript keeps the last). For inputs up to 500,000 characters, the scanner inspects every object scope and lists up to four repeated keys in a warning banner.

Catching repeated keys early prevents subtle configuration overrides and JSON Parameter Pollution bugs where an authentication gateway reads the first "role" field while a downstream microservice reads the last one. Fixing duplicates before saving ensures every parser produces identical data.

Sorting keys alphabetically and handling large files

Alphabetical key sorting and background worker offloading make large API responses predictable to compare and responsive to edit. Turning on Sort keys A–Z orders every nested object recursively using locale-aware comparison without altering array element order.

Deterministic key ordering for clean diffs

Two API responses with identical data often produce noisy line-by-line diffs when servers serialize object properties in different insertion orders. Checking Sort keys A–Z normalizes key ordering across every nested level in both Format and Tree modes so structural changes stand out immediately.

Background Web Worker offloading above 64 KB

Payloads under 65,536 characters (64 KB) format synchronously as you type, whereas larger inputs and .json files up to 20 MB switch automatically to a background thread. Following the MDN Using Web Workers API Guide, offloading heavy serialization with a 120 ms debounce keeps typing and scrolling responsive.

Tip: When comparing a large 20 MB export against a database query, use Minify for compact storage or Sort keys A–Z before running a diff.

If your debugging session also involves inspecting database queries alongside API payloads, open the SQL formatter in this tab without uploading anything.

Questions

Does strict JSON allow comments or single quotes?

No. Both IETF RFC 8259 and ECMA-404 prohibit // and /* */ comments, single-quoted strings, unquoted property names, and trailing commas. When pasted text contains JavaScript or JSONC syntax, the validator flags the exact line and column with a plain-English fix hint.

What does an Unexpected token error mean in JSON?

An Unexpected token error means the parser hit a character that violates JSON grammar at that offset, such as a trailing comma before a closing brace or an unquoted key. Select Go to line in the alert banner to jump directly to the offending line.

How does this formatter avoid rounding 64-bit database IDs?

Standard browser JSON.parse() converts every number into an IEEE 754 float, rounding integers above 9007199254740991 (2^53 - 1). After verifying strict RFC 8259 syntax, this parser keeps integers exceeding 53 bits as exact BigInt tokens across Format, Minify, Sort keys A–Z, and Tree view.

Why does the validator warn about duplicate keys in valid JSON?

RFC 8259 recommends unique member names inside each object, yet standard parsers accept repeated keys and overwrite earlier values with the final entry. Scanning inputs up to 500,000 characters highlights repeated property names in a warning banner before shadowed config fields cause bugs.

When should I use Minify instead of Format?

Choose Format with 2 spaces, 4 spaces, or Tabs when reading API responses, debugging webhooks, or committing readable test fixtures. Switch to Minify to strip optional whitespace and line breaks before embedding payloads in environment variables, log lines, or compact HTTP bodies.

How large a JSON file can I open in the browser?

You can paste text or open local .json and .txt files up to 20 MB. Payloads under 64 KB update synchronously as you type, while inputs above 64 KB run inside a background Web Worker with a 120 ms debounce.

Updated