Tools > JSONJSON Formatter
Indent size
Input
Output
Valid JSONNo
Lines0
Depth0
Size (bytes)0

JSON Formatter & Beautifier

Format and beautify raw, minified, or poorly formatted JSON into cleanly indented output with full control over the formatting style. This tool supports JSONC (JSON with Comments), trailing comma removal, compact/minified output, recursive inlining of nested arrays and objects, and unicode escaping — all formatting and beautifying happens in your browser for complete privacy.

How to Use This Tool

  1. Paste your JSONPaste raw, minified, or messy JSON into the input panel. The tool accepts standard JSON and optionally JSONC (with comments and trailing commas).
  2. Choose indentation styleSelect spaces or tabs for indentation. Use the slider or type a value to adjust the indent size (up to 20 levels) to match your project's coding style.
  3. Configure formatting optionsEnable "Minify" for compact output, or fine-tune with recursive inlining of short arrays and objects, empty structure collapsing, and unicode escaping. Use the threshold sliders to control how aggressively structures are inlined.
  4. Handle JSONC inputIf your input contains comments (like tsconfig.json or VS Code settings), enable "Strip comments" and "Strip trailing commas" to convert it to valid JSON.
  5. Copy the resultThe formatted JSON appears instantly in the output panel. Click the copy button to copy it to your clipboard.

Features

Customizable Indentation

Choose between spaces and tabs with a configurable indent size up to 20 levels. Use the interactive slider for quick adjustments or type any value directly.

Minify / Compact Mode

Compress JSON to a single line by removing all whitespace — ideal for reducing payload size or embedding in URLs and APIs.

JSONC Support

Strip single-line (//) and multi-line (/* */) comments from JSONC files like tsconfig.json, VS Code settings.json, and ESLint configs before formatting.

Trailing Comma Removal

Automatically remove trailing commas before ] and } to convert JSON5-like input into strict JSON.

Recursive Inline Short Arrays & Objects

Recursively inline arrays and objects — including deeply nested structures — onto a single line when they fit within the configurable character threshold (up to 1000 chars). A nested object like {"pool":{"min":2,"max":10}} stays compact when it fits, while larger structures expand normally.

Unicode Escaping

Convert non-ASCII characters in string values to \uXXXX escape sequences for ASCII-safe JSON output compatible with legacy systems.

Real-World Use Cases

1

Debugging API Responses

Paste a minified API response to instantly see the full structure with proper indentation, making it easy to inspect nested objects and arrays.

2

Formatting Config Files

Clean up messy tsconfig.json, package.json, or VS Code settings files with consistent indentation and optional comment stripping.

3

Minifying JSON Payloads

Compress formatted JSON to a single compact line for embedding in environment variables, API request bodies, or URL parameters.

4

Normalizing Team Formatting

Ensure all team members use the same JSON formatting style (2-space indent, collapsed empty structures) for consistent code reviews and diffs.

5

Preparing ASCII-Safe JSON

Escape unicode characters for systems that require ASCII-only JSON, such as older databases or legacy APIs that don't support UTF-8.

Frequently Asked Questions

What is JSONC and how does this tool handle it?
JSONC (JSON with Comments) is JSON that allows single-line (//) and multi-line (/* */) comments, plus trailing commas. Many tools like TypeScript (tsconfig.json) and VS Code (settings.json) use JSONC. Enable "Strip comments" and "Strip trailing commas" to convert JSONC input into valid standard JSON before formatting.
What does the "Inline short arrays" option do?
When enabled, arrays that fit within the character threshold (default 80) stay on a single line — like [1, 2, 3] — instead of expanding each element to its own line. This works recursively: arrays containing nested objects or other arrays are also inlined as long as the entire serialized form fits within the threshold. Use the slider to adjust the threshold up to 1000 characters.
Does inlining work with nested objects and arrays?
Yes. Inlining is fully recursive. A structure like {"pool":{"min":2,"max":10}} or ["tags",[1,2,3]] will stay on a single line as long as the entire serialized form fits within the character threshold. This makes the output significantly more readable for config files and API responses with small nested structures.
Does minify mode validate my JSON?
Yes. The tool parses your input as JSON before formatting. If the input is invalid JSON (and pre-processing like comment/comma stripping doesn't fix it), you'll see an error instead of output. The "Valid JSON" indicator in the stats bar confirms whether parsing succeeded.
Why would I escape unicode characters?
Some legacy systems, APIs, or databases don't handle UTF-8 JSON correctly. Escaping non-ASCII characters to \uXXXX sequences ensures the JSON contains only ASCII characters while preserving the actual values. For example, "cafe" becomes "caf\u00e9".
Is my data safe? Does it get sent to a server?
Your data never leaves your browser. All JSON formatting, parsing, and transformation happens entirely client-side in JavaScript. No data is sent to any server, making this tool safe for sensitive or confidential JSON data.
What is the maximum JSON size this tool can handle?
Since processing happens in your browser, the limit depends on your device's memory. Most modern browsers can handle JSON files of several megabytes without issues. For very large files (50MB+), processing may be slow.

Related Tools