JSON Formatting
Notepad++ Guide
Coding Tutorials
Data Manipulation
Software Tips

How to reformat JSON in Notepad++

Master System Design with Codemia

Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.

Introduction

Notepad++ can format (pretty-print) JSON in one click using the built-in JSTool plugin or the JSON Viewer plugin. Once installed, you select your minified JSON, run the formatter, and the output becomes indented and readable. This guide covers every method, keyboard shortcuts, validation, and alternatives.

JSTool ships with recent Notepad++ installs. If it is already in your Plugins menu, skip to step 3.

Installation

  1. Open Notepad++.
  2. Go to Plugins > Plugins Admin.
  3. Search for JSTool.
  4. Check the box and click Install. Notepad++ will restart.

Formatting JSON

  1. Open or paste your JSON into a new tab.
  2. Go to Plugins > JSTool > JSFormat.
  3. Your JSON is now indented.

Keyboard shortcut: Ctrl+Alt+M formats the entire document by default.

Minifying JSON

To reverse the process and compress JSON onto a single line:

  1. Go to Plugins > JSTool > JSMin.
  2. Or press Ctrl+Alt+N.

Example

Before (minified):

json
{"users":[{"id":1,"name":"Alice","roles":["admin","editor"]},{"id":2,"name":"Bob","roles":["viewer"]}],"total":2}

After Ctrl+Alt+M (formatted):

json
1{
2    "users": [
3        {
4            "id": 1,
5            "name": "Alice",
6            "roles": [
7                "admin",
8                "editor"
9            ]
10        },
11        {
12            "id": 2,
13            "name": "Bob",
14            "roles": [
15                "viewer"
16            ]
17        }
18    ],
19    "total": 2
20}

Method 2: JSON Viewer Plugin

JSON Viewer provides formatting plus a tree view that lets you visually browse the structure.

Installation

  1. Plugins > Plugins Admin.
  2. Search for JSON Viewer.
  3. Install and restart.

Formatting

  1. Open your JSON file.
  2. Go to Plugins > JSON Viewer > Format JSON.

Tree View

Select Plugins > JSON Viewer > Show JSON Viewer to open a dockable panel with a collapsible tree. This is useful for navigating deeply nested objects without scrolling through thousands of lines.

Method 3: Python Script Plugin (Advanced)

If you prefer full control or want to customize indentation, you can use the Python Script plugin.

  1. Install Python Script from Plugins Admin.
  2. Go to Plugins > Python Script > New Script. Name it FormatJSON.py.
  3. Paste:
python
1import json
2
3text = editor.getText()
4try:
5    parsed = json.loads(text)
6    formatted = json.dumps(parsed, indent=2, ensure_ascii=False)
7    editor.setText(formatted)
8except ValueError as e:
9    notepad.messageBox("Invalid JSON: " + str(e), "Error")
  1. Run with Plugins > Python Script > Scripts > FormatJSON.

This approach lets you change the indent size, sort keys, or strip Unicode escapes.

Setting Custom Keyboard Shortcuts

Neither JSON Viewer nor Python Script has a default shortcut. To assign one:

  1. Go to Settings > Shortcut Mapper.
  2. Click the Plugin commands tab.
  3. Find the command (e.g., "Format JSON" or "JSFormat").
  4. Double-click it and set your preferred key combination.

A common choice is Ctrl+Shift+J for format and Ctrl+Shift+M for minify.

Validating JSON Before Formatting

Formatting will fail silently or throw errors if your JSON is malformed. Common problems:

ProblemExampleFix
Trailing comma{"a": 1,}Remove the comma after the last value
Single quotes{'a': 1}Replace with double quotes
Unquoted keys{a: 1}Wrap keys in double quotes
Comments// note or /* */Remove comments (JSON does not allow them)
Missing colon{"a" 1}Add : between key and value

To validate without formatting, use Plugins > JSON Viewer > Check JSON syntax or paste into an online tool like JSONLint.

Comparison: Formatting Methods

FeatureJSToolJSON ViewerPython Script
Pretty-printYesYesYes
MinifyYesYes (Compact JSON)Manual
Tree viewNoYesNo
Custom indentNoNoYes
Sort keysNoNoYes
Default shortcutCtrl+Alt+MNoneNone
Handles large files (100MB+)GoodSlowerDepends

Alternatives Outside Notepad++

If you work with JSON frequently, these command-line and editor alternatives can be faster:

Command line (Python, already installed on most systems):

bash
python -m json.tool input.json > output.json

Command line (jq):

bash
cat input.json | jq '.' > output.json

VS Code: Open any .json file and press Shift+Alt+F (Windows) or Shift+Option+F (macOS) to format.

Browser DevTools: Paste JSON into the console with JSON.stringify(JSON.parse(text), null, 2).

Common Pitfalls

  • BOM characters. Files saved as UTF-8 with BOM can cause the first character to be invisible but invalid. Switch encoding to UTF-8 (without BOM) in Encoding > Convert to UTF-8.
  • Large files freeze Notepad++. For files over 100 MB, use jq on the command line instead.
  • Encoding issues with special characters. If accented characters break after formatting, ensure your file encoding matches the JSON content (UTF-8 is almost always correct).
  • Plugin not appearing after install. Check that the plugin architecture (32-bit vs 64-bit) matches your Notepad++ version.
  • Formatting only part of a file. Select just the JSON portion before running the formatter. If no text is selected, the plugin formats the entire document.

Summary

  • Install the JSTool plugin for the fastest one-shortcut formatting (Ctrl+Alt+M to format, Ctrl+Alt+N to minify).
  • Use JSON Viewer if you need a tree view to navigate complex structures.
  • Use the Python Script plugin for custom indent sizes or key sorting.
  • Always validate JSON before formatting to avoid silent failures.
  • For files over 100 MB, use command-line tools like jq or python -m json.tool.
  • Set custom keyboard shortcuts through Settings > Shortcut Mapper > Plugin commands.

Course illustration
Course illustration

All Rights Reserved.