Auto Format JSON
online — paste & done
Just paste your JSON and get perfectly formatted, syntax-highlighted output instantly. No buttons to click, no configuration needed. Your data stays in your browser — always private, always fast.
Open Auto JSON FormatterPaste once, formatted instantly
The fastest way to format JSON
100% Private
Your JSON never leaves your device. There is no server — everything runs in your browser.
Zero-Click Formatting
Paste triggers formatting automatically. No buttons, no configuration, no delays.
PWA & Offline
Install as an app on any device. Works offline after the first visit.
Related JSON tools
Common questions answered
How does auto-formatting work?
When you paste JSON into the input field, the formatter automatically detects the paste event and formats your JSON with proper indentation, syntax highlighting, and a collapsible tree view — no button click required. Just paste and see the result.
Does the auto-formatter handle large JSON files?
Yes. Because all processing happens in your browser, there is no server-imposed size limit. The formatter uses efficient parsing and lazy rendering, so even multi-megabyte JSON files are handled smoothly. Tree view nodes are rendered on demand for optimal performance.
Can I configure the indentation or style?
The default output uses 2-space indentation with syntax highlighting. You can also switch between Code view, Tree view (collapsible), and Table view for arrays of objects — all from the Format tab without re-pasting your data.
Does it work offline?
Yes. jsonfmt.dev is a Progressive Web App (PWA) with a service worker that caches all assets. After your first visit, you can format JSON even without an internet connection.
Is my JSON data private?
Completely. The auto-formatter runs 100% client-side in your browser. Your data is never sent to a server, never stored, and never logged. You can verify this by opening your browser's Network tab — no data requests are made.
What is auto-formatting for JSON?
Auto-formatting detects and corrects JSON layout issues without manual intervention. When you paste JSON into this tool, it automatically identifies whether the input is minified, partially indented, or irregularly formatted, then applies consistent indentation rules. There is no "Format" button to click — the output updates as you type or paste.
Auto-formatters go beyond simple indentation. This tool also detects the input encoding, handles BOM (Byte Order Mark) characters, strips trailing whitespace, and normalizes line endings. If the input contains syntax errors, the auto-formatter highlights the exact position and suggests repairs — useful as a first step when working with unfamiliar JSON from external sources.
{
"name": "Alice",
"age":30,
"city": "Portland"
}
{
"name": "Alice",
"age": 30,
"city": "Portland"
}
Get the most out of this tool
- Paste JSON from any source — the auto-formatter handles inconsistent indentation, extra whitespace, and encoding issues.
- Use auto-format as a pre-validation step when receiving JSON from third-party APIs or user uploads.
- Combine auto-format with the Repair tab to fix and format broken JSON in a single workflow.
How automatic JSON formatting works
Automatic JSON formatting — often called "format-on-paste" or "auto-format" — detects when JSON is pasted into an input field and immediately applies consistent formatting without requiring any user action. The key challenge is reliably detecting JSON input versus other text. A robust auto-formatter checks whether the trimmed input starts with { or [, attempts a parse, and only formats on parse success — avoiding false positives on non-JSON text that happens to start with a brace.
The formatting pipeline runs in two phases. First, the lexer tokenizes the raw JSON string into a sequence of tokens — strings, numbers, booleans, null, and structural characters. Second, the formatter traverses this token stream and re-emits it with normalized whitespace: consistent indentation (typically 2 spaces per nesting level), a space after colons in objects, and newlines after commas at the same nesting level. This two-phase approach handles minified JSON, inconsistently indented JSON, and tab-indented JSON all identically.
Auto-formatting on paste is particularly valuable in development workflows because JSON copied from browser network inspectors, curl output, or log files is frequently minified — all on one line with no whitespace. Re-formatting this manually is tedious and error-prone. Automatic formatting eliminates this friction, presenting readable structure immediately after paste without requiring a manual format button click.
Detection heuristics for auto-formatting must balance sensitivity and specificity. Too sensitive, and the formatter triggers on non-JSON text that superficially resembles JSON — causing unexpected behavior when pasting code snippets or YAML. Too specific, and valid JSON is not detected. The optimal heuristic: trim the input, check that it begins with { or [, attempt a parse with a generous timeout, and format only on successful parse with no errors.
Large JSON documents (over 100KB) require special handling during auto-format. Synchronous formatting in the browser's main thread blocks UI rendering, causing the page to freeze during the format operation. Web Workers solve this by offloading the formatting computation to a background thread, allowing the UI to remain responsive while the format operation completes. The formatted result is sent back to the main thread via postMessage when ready.
Indentation preferences vary by team and project. The most common choices are 2 spaces (JavaScript ecosystem convention), 4 spaces (Python and Java conventions), and tabs (Go convention). An auto-formatter should respect the user's preferred indentation setting rather than forcing a single style. Storing the preference in localStorage ensures the setting persists across sessions without requiring sign-in.
Integration with code editors extends auto-format capabilities. VS Code's JSON language server provides format-on-save functionality that runs the same indentation normalization on save. The prettier formatter also handles JSON files, applying consistent style as part of a broader project-wide formatting setup. Browser-based auto-formatters like this tool complement editor-based formatting by providing a quick, always-accessible option without requiring project setup or editor configuration.
When auto-format JSON tools are most useful
Getting the most from JSON auto-formatting
- Set your indentation preference once: Choose your team's preferred indentation (2 spaces, 4 spaces, or tabs) and save it as your default. Consistent indentation across all JSON files in a project reduces version control noise from whitespace-only changes when different team members use different settings.
- Use format-on-save in your code editor: Browser auto-formatters are great for inspection, but integrate formatting into your development workflow with editor plugins. VS Code's built-in JSON formatter, Prettier, and ESLint all support JSON formatting on file save, ensuring consistent style without manual intervention.
- Don't mistake formatting for validation: Auto-formatting succeeds when JSON is structurally valid, but a validly formatted JSON file can still contain semantically incorrect data — wrong field names, incorrect value types, missing required fields. Use JSON Schema validation in addition to formatting for complete data quality assurance.
- Sort keys for better version control diffs: When committing JSON files to version control, sort keys alphabetically before formatting. This produces stable diffs where key additions appear in predictable positions rather than being interleaved with existing keys, making code review easier.
Additional frequently asked questions
Does auto-formatting change the JSON data or just the whitespace?
Auto-formatting only modifies whitespace — indentation, line breaks, and spaces around colons and commas. The data values, key names, key order, and data types remain exactly unchanged. The resulting JSON is semantically identical to the input; only its visual presentation changes to improve readability.
Will auto-format detect JSON embedded in other text?
Auto-format detects JSON by looking for input that begins (after whitespace trimming) with { or [ and successfully parses as JSON. If you paste text that starts with JSON followed by non-JSON content, or JSON embedded mid-paragraph in other text, the detection may fail. For best results, paste only the JSON portion.
Can auto-formatting handle very large JSON files?
Yes — large files over 100KB are processed in a Web Worker background thread to keep the browser UI responsive during formatting. The formatted output is returned when processing completes. Very large files (multiple megabytes) may take several seconds. For production use with large files, consider command-line tools like jq '.' which process files much faster.
Why does auto-format sometimes not trigger when I paste?
Auto-format triggers only when the pasted content successfully parses as valid JSON. If the pasted JSON contains syntax errors — trailing commas, single quotes, comments, or truncated content — the parse fails and auto-format is suppressed. Use the Repair tab to fix syntax errors first, then paste the repaired JSON to trigger auto-formatting.