ctrl+shift+p filters: :st2 :st3 :win :osx :linux
Browse

Json​5​Formatter

by RAMBOO1990 ST4

No description provided

Details

Installs

  • Total 2K
  • Win 783
  • Mac 1K
  • Linux 273
Nov 3 Nov 2 Nov 1 Oct 31 Oct 30 Oct 29 Oct 28 Oct 27 Oct 26 Oct 25 Oct 24 Oct 23 Oct 22 Oct 21 Oct 20 Oct 19 Oct 18 Oct 17 Oct 16 Oct 15 Oct 14 Oct 13 Oct 12 Oct 11 Oct 10 Oct 9 Oct 8 Oct 7 Oct 6 Oct 5 Oct 4 Oct 3 Oct 2 Oct 1 Sep 30 Sep 29 Sep 28 Sep 27 Sep 26 Sep 25 Sep 24 Sep 23 Sep 22 Sep 21 Sep 20 Sep 19
Windows 0 7 5 3 5 16 7 8 8 4 3 7 8 9 6 8 2 4 5 5 7 12 13 6 3 9 9 4 9 9 3 3 10 13 8 16 13 4 2 13 8 12 13 10 6 4
Mac 0 9 3 2 12 6 12 8 10 3 7 2 18 13 12 9 5 5 8 14 7 10 12 4 3 13 17 7 9 13 3 6 8 13 17 15 23 1 7 12 14 8 15 21 10 3
Linux 0 2 1 2 1 4 4 4 3 0 1 4 2 2 4 1 0 2 1 3 4 3 3 4 3 3 2 1 4 3 2 1 2 4 3 5 1 1 2 4 5 3 6 5 0 2

Readme

Source
raw.​githubusercontent.​com

English | 中文

Json5Formatter

A Sublime Text plugin that formats JSON/JSON5 files using the system Python's json5 library.

Features

Command Description
JSON5: Format as JSON Format and output standard JSON, preserving comments
JSON5: Format as JSON5 Format as JSON5 style (comments not preserved)
JSON5: Minify Compress to single-line JSON
  • Supports JSON5 syntax: // and /* */ comments, single-quoted strings, trailing commas, unquoted keys
  • Auto-converts single quotes → double quotes, unquoted keys → quoted keys
  • Outputs standard JSON (no trailing commas)

Installation

Prerequisites

  • Python 3.x (on system PATH)
  • json5 library: pip install json5

Package Control (Recommended)

Search for Json5Formatter in Package Control:

  1. Ctrl+Shift+P → Package Control: Install Package
  2. Type Json5Formatter → Enter

Manual Install

Sublime Text 4

cd <Packages directory>   (Preferences → Browse Packages...)
git clone git@github.com:RAMBOO1990/sublime-json5.git "Json5Formatter"

Usage

Command Palette

Press Ctrl+Shift+P, type JSON5:, and select the desired command.

Key Binding

Keys Command
Ctrl+Shift+J Format as JSON

Customize in Default.sublime-keymap.

Settings

Preferences → Package Settings → Json5Formatter → Settings

{
    // Number of spaces per indent level
    "indent": 4,
    // Sort object keys alphabetically
    "sort_keys": false,
    // Escape non-ASCII characters
    "ensure_ascii": false
}

sort_keys and ensure_ascii only apply to the Format as JSON5 and Minify commands. Format as JSON uses the built-in formatter and does not currently support these options.

License

MIT