How to Format JSON in IntelliJ: Shortcuts & Auto-Format Setup (2026)

IntelliJ has built-in JSON formatting - no plugins needed. Press Ctrl+Alt+L (Windows/Linux) or Cmd+Option+L (Mac) on any JSON file to format it instantly.
Method 1: Keyboard Shortcut (Fastest)
- Open your JSON file in IntelliJ
- Press Ctrl+Alt+L (Windows/Linux) or Cmd+Option+L (Mac)
- Done - IntelliJ reformats with consistent indentation
Before formatting:
{"name":"John","age":30,"skills":["Java","Python"],"active":true}
After Ctrl+Alt+L:
{
"name": "John",
"age": 30,
"skills": [
"Java",
"Python"
],
"active": true
}
Method 2: Right-Click Menu
- Right-click anywhere in the JSON file
- Select "Reformat Code"
This does exactly the same thing as the keyboard shortcut but through the context menu.
Method 3: Configure Formatting Rules
- Go to Settings/Preferences → Editor → Code Style → JSON
- Adjust indent size, spacing around colons, max line length
- Apply → OK → reformat with Ctrl+Alt+L
Key settings to configure:
- Tab size: Set to 2 or 4 spaces based on your team standards
- Indent: Choose spaces or tabs
- Space after colon: Add space after in key-value pairs
: - Wrap arrays: Control when arrays wrap to new lines
Formatting on Save (Auto-Format)
- Settings → Tools → Actions on Save
- Check "Reformat code"
- Now JSON formats automatically every time you save
This is the most convenient option. Your JSON stays formatted without thinking about it.
JSON Validation and Error Detection
IntelliJ validates JSON syntax in real-time. Common errors it catches:
Trailing commas (invalid JSON):
{
"name": "John",
"age": 30,
}
IntelliJ highlights the trailing comma and offers a quick fix.
Single quotes (invalid JSON):
{
'name': 'John'
}
IntelliJ shows an error and can convert to double quotes with Alt+Enter.
Missing commas:
{
"name": "John"
"age": 30
}
IntelliJ indicates where commas are missing.
Advanced JSON Features
JSON Schema validation: Go to Settings → Languages & Frameworks → Schemas and DTDs → JSON Schema Mappings to validate against schemas.
JSON Path testing: IntelliJ supports JSON Path expressions for extracting data from JSON structures.
Quick navigation: Use Ctrl+F12 (Windows/Linux) or Cmd+F12 (Mac) to see the JSON structure outline.
Frequently Asked Questions
What's the shortcut to format JSON in IntelliJ?
Ctrl+Alt+L on Windows/Linux or Cmd+Option+L on Mac. This works for any file type in IntelliJ, not just JSON. You can also use Ctrl+Shift+Alt+L to open the format dialog with additional options.
How do I auto-format JSON on save in IntelliJ?
Go to Settings → Tools → Actions on Save and check "Reformat code". This applies to all file types. You can also enable "Optimize imports" and "Rearrange code" for additional cleanup on save.
Why isn't my JSON formatting in IntelliJ?
Check that IntelliJ recognizes the file as JSON (look at the bottom right corner for file type). If it shows "Text" instead of "JSON", right-click the file and choose "Associate with File Type" → JSON. Also verify your JSON is syntactically valid.
Can IntelliJ validate JSON as well as format it?
Yes, IntelliJ validates JSON syntax automatically and highlights errors in red. You can also configure JSON Schema validation for structure validation beyond syntax. Use Alt+Enter on highlighted errors for quick fixes and suggestions.
How do I change the JSON indent size in IntelliJ?
Go to Settings → Editor → Code Style → JSON. Change the "Tab size" and "Indent" values. Set to 2 for compact formatting or 4 for more readable formatting. Click "Apply" then reformat your JSON with Ctrl+Alt+L.
Read More
All Articles
How JSON Powers Everything: APIs, Web Apps & Real-Time Data (2026)
Discover how JSON powers modern web applications, REST APIs, and real-time systems. Learn why JSON became the universal data format for web development, mobile apps, and cloud services.

How to Add Image in JSON: URL, Base64 & File Path Methods (2026)
Add images to JSON using URLs, base64 encoding, or file paths. Complete guide with code examples, size optimization tips, and best practices for each method in web and mobile apps.

How to Merge GPX Files: Free Tool + Python + GPSBabel Guide (2026)
Merge multiple GPX files into one using free online tool, Python, or GPSBabel. Complete guide for combining GPS tracks, waypoints, and routes from Garmin, Strava, Komoot, and other devices.