Need help with your JSON?
Try our JSON Formatter tool to automatically identify and fix syntax errors in your JSON. JSON Formatter tool
IntelliJ IDEA JSON Formatter and Debugging Capabilities
If you searched for how to format JSON in IntelliJ IDEA, the short answer is simple: open the .json file and run Code > Reformat Code. IntelliJ's built-in formatter handles indentation, spacing, wrapping, folding, schema-aware validation, and large-file navigation well for valid JSON.
Where IntelliJ becomes more useful than a basic pretty-printer is the rest of the workflow: it flags invalid JSON while you type, can validate files against JSON Schema, supports JSON5, lets you test JSONPath queries, and can show JSON strings in a structured debugger view when you stop at a breakpoint.
Quick Answer: How To Format a JSON File in IntelliJ IDEA
- Open the JSON file in the editor.
- Run
Code > Reformat Code. - If you only want part of the file formatted, select that block first and then run reformat.
- If you want formatting applied automatically, enable
Tools > Actions on Saveand turn on reformat for the file types you care about.
IntelliJ formats JSON using the current code style rules, including relevant .editorconfig settings when present. If the formatter does not change anything, the most common reason is that the file is already compliant with the active style rules.
What IntelliJ's JSON Formatter Actually Helps With
For searchers looking for an IntelliJ JSON formatter, the built-in formatter is usually enough for everyday work: cleaning up API fixtures, normalizing config files, or re-indenting pasted payloads. You do not need a plugin for standard JSON formatting.
- Pretty-print a minified JSON file so nested objects and arrays become readable.
- Format only the current selection when you want to leave surrounding text untouched.
- Reformat on save if you want JSON files normalized automatically during edits.
- Keep style consistent across a project by combining IntelliJ's formatter with shared code-style or
.editorconfigrules.
The important limitation is that formatting is not repair. If the file has a missing quote, a missing comma, or another syntax error, the formatter will not magically fix the data. IntelliJ will highlight the problem, but you still need to correct the invalid JSON first.
Validation, JSON5, and Schema Support
Current IntelliJ IDEA documentation is stronger on validation than many older articles suggest. The editor supports JSON Schema out of the box, including bundled schemas from SchemaStore and custom schema mappings for your own project files.
That matters because formatting alone does not tell you whether a file is valid for the tool that will read it. A schema-backed file can show enum errors, missing required keys, invalid value types, and other structural issues before runtime.
- Use schema mappings when your team has custom config files that are JSON-shaped but have strict rules.
- Check the status bar if IntelliJ seems to validate against the wrong schema.
- If your file contains comments or trailing commas, confirm whether you are editing strict JSON or JSON5, because IntelliJ supports both but they are not interchangeable.
Debugging JSON Strings at a Breakpoint
This is where the article's original topic still matters. JetBrains documents a structured viewer for string expressions in the debugger: when a stopped value contains JSON or XML, IntelliJ can display it in a formatted document view instead of forcing you to inspect one long escaped string.
In practice, that helps most when you are debugging API clients, serializers, queue consumers, or config loaders and want to inspect the exact payload before parsing. It is far faster than copying the value into a temporary file every time you hit a breakpoint.
Evaluate Expressions for Parsed Data
If the JSON has already been parsed into native objects, IntelliJ's Evaluate Expression feature is the better tool. You can inspect nested fields, array items, or transformed values using the language you are debugging rather than working from raw text.
A useful split is:
- Use the structured string viewer when the payload is still raw JSON text.
- Use Evaluate Expression when the payload is already mapped into objects, dictionaries, or arrays.
JSONPath Is Better Than Manual Scrolling
IntelliJ IDEA also supports evaluating JSONPath expressions against open JSON content. For large payloads, this is usually the fastest way to answer practical questions like "which item has this ID?" or "what value did this nested flag resolve to?"
Useful JSONPath examples
$.items[0]returns the first item in an array.$..idfinds everyidkey anywhere in the document.$.users[?(@.active == true)]filters users down to active entries.$.config.features[*].nameextracts all feature names from a nested config object.
If you regularly inspect large REST responses, JSONPath is the part of IntelliJ's JSON tooling most people underuse.
Scratch Files Are Still the Fastest Safe Workspace
Scratch files remain a good place to paste a payload from logs, reformat it, attach the right schema, and run JSONPath queries without creating noise inside your repository. For quick investigation work, this is usually cleaner than adding temporary files to the project tree.
When Reformat Code Does Not Work
- The file is invalid JSON, so IntelliJ highlights the error but cannot cleanly reformat the broken structure.
- The content is not actually treated as JSON. This happens with the wrong file extension or when JSON is embedded in a plain-text file.
- You expect Prettier to handle JSON automatically, but its configured file pattern does not include JSON in your project.
- You are editing JSON5 features such as comments or trailing commas while the file is meant to stay strict JSON.
If the goal is simply to clean up malformed pasted data before bringing it back into IntelliJ, a standalone JSON formatter can be the faster first step. IntelliJ is strongest once the file is valid and part of a real editing or debugging workflow.
Conclusion
For most developers, the answer to "How do I format JSON in IntelliJ IDEA?" is just Reformat Code. The reason to stay in IntelliJ instead of using a one-off formatter is everything around that action: schema validation, JSON5 awareness, JSONPath queries, scratch files, and structured JSON inspection in the debugger. That combination is what makes IntelliJ IDEA genuinely useful for JSON-heavy debugging work rather than just decent at indentation.
Need help with your JSON?
Try our JSON Formatter tool to automatically identify and fix syntax errors in your JSON. JSON Formatter tool