Swiss knife for JSON operations - A VSCode extension and CLI tool for validating, formatting, minifying, stringifying, parsing, and sorting JSON.
| Feature | Description | Keyboard Shortcut |
|---|---|---|
| Validate | Check if JSON is valid, with error position highlighting | Ctrl+Alt+V / Cmd+Alt+V |
| Format | Pretty-print JSON with customizable indentation | Ctrl+Alt+F / Cmd+Alt+F |
| Minify | Remove all whitespace for compact JSON | Ctrl+Alt+M / Cmd+Alt+M |
| Stringify | Escape special characters (quotes, backslashes, newlines) | Ctrl+Alt+G / Cmd+Alt+G |
| Parse | Convert stringified JSON back to formatted JSON | Ctrl+Alt+P / Cmd+Alt+P |
| Sort Keys | Sort object keys alphabetically (A-Z or Z-A) | Ctrl+Alt+S / Cmd+Alt+S |
- Selection Support: Apply operations to selected text or the entire document
- Format Document Hook: Use VSCode's built-in "Format Document" (
Shift+Alt+F) with JSONPlus - Context Menu: Right-click to access all operations via the JSONPlus submenu
- Auto Language Detection: Automatically sets file language to JSON after operations
- Detailed Error Messages: Shows exact line and column for JSON errors
- CLI Tool: Use JSONPlus from the command line or in scripts
- Open a JSON file or select JSON text
- Press
Ctrl+Shift+P/Cmd+Shift+Pto open Command Palette - Type "JSONPlus" to see all available commands
- Right-click in the editor
- Select "JSONPlus" from the context menu
- Choose the desired operation
Use the keyboard shortcuts listed in the features table above.
Select a portion of text to apply operations only to that selection. If no selection is made, the operation applies to the entire document.
// Input (invalid)
{"name": "John", "age": }
// Output: Error message
// "Invalid JSON at line 1, column 24: Unexpected token }"// Input
{"name":"John","age":30,"city":"New York"}
// Output (with default 2-space indent)
{
"name": "John",
"age": 30,
"city": "New York"
}// Input
{
"name": "John",
"age": 30
}
// Output
{"name":"John","age":30}// Input
{"key": "value"}
// Output
"{\"key\": \"value\"}"// Input
"{\"key\": \"value\"}"
// Output
{
"key": "value"
}// Input
{"zebra": 1, "apple": 2, "mango": 3}
// Output (ascending)
{
"apple": 2,
"mango": 3,
"zebra": 1
}Configure JSONPlus via VSCode Settings (Ctrl+, / Cmd+,):
| Setting | Default | Description |
|---|---|---|
jsonplus.format.enable |
true |
Enable as formatting provider for Format Document |
jsonplus.format.indentSize |
2 |
Number of spaces for indentation |
jsonplus.format.useTabs |
false |
Use tabs instead of spaces |
jsonplus.format.insertFinalNewline |
true |
Add trailing newline when formatting |
jsonplus.sortKeys.recursive |
true |
Sort keys in nested objects |
jsonplus.sortKeys.order |
"ascending" |
Sort order: "ascending" or "descending" |
jsonplus.autoSetLanguage |
true |
Auto-set language to JSON after operations |
jsonplus.showNotifications |
true |
Show success/error notifications |
{
"jsonplus.format.indentSize": 4,
"jsonplus.format.useTabs": true,
"jsonplus.sortKeys.order": "descending"
}JSONPlus also provides a command-line interface.
npm install -g jsonplus-cli# Validate JSON
jsonplus validate input.json
# Format JSON
jsonplus format input.json
jsonplus format --indent 4 input.json
jsonplus format --tabs input.json
# Minify JSON
jsonplus minify input.json
jsonplus minify input.json -o output.json
# Stringify
jsonplus stringify input.json
# Parse stringified JSON
jsonplus parse input.json
# Sort keys
jsonplus sort input.json
jsonplus sort --desc input.json
jsonplus sort --no-recursive input.json# Pipe from stdin
echo '{"b":1,"a":2}' | jsonplus sort
cat data.json | jsonplus minify
# Output to file
cat data.json | jsonplus format -o formatted.json| Option | Description |
|---|---|
--indent <n> |
Indentation size in spaces (default: 2) |
--tabs |
Use tabs instead of spaces |
--desc |
Sort in descending order (Z-A) |
--no-recursive |
Don't sort nested objects |
--no-newline |
Don't add trailing newline |
-o, --output |
Output file (default: stdout) |
-h, --help |
Show help |
-v, --version |
Show version |
.json- Standard JSON files.jsonc- JSON with Comments (VSCode's format)
.json5- JSON5 extended format.jsonl- JSON Lines (newline-delimited JSON)
- Open VSCode
- Go to Extensions (
Ctrl+Shift+X/Cmd+Shift+X) - Search for "JSONPlus"
- Click Install
For VSCodium or other editors:
- Go to Open VSX Registry
- Search for "JSONPlus"
- Click Install
git clone https://github.com/yourusername/jsonplus.git
cd jsonplus
npm installnpm run compilenpm run testnpm run package# VS Code Marketplace
npm run publish:vscode
# Open VSX Registry
npm run publish:ovsxJSONPlus/
├── src/
│ ├── extension.ts # Extension entry point
│ ├── core/ # Pure logic (no VSCode deps)
│ │ ├── validator.ts
│ │ ├── formatter.ts
│ │ ├── minifier.ts
│ │ ├── stringifier.ts
│ │ ├── parser.ts
│ │ └── sorter.ts
│ ├── commands/ # VSCode command handlers
│ ├── providers/ # Formatting provider
│ └── utils/ # Helper utilities
└── cli/ # CLI package
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Make your changes
- Run tests (
npm test) - Submit a pull request
MIT License - see LICENSE for details.
See CHANGELOG.md for version history.