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

Json​5​Formatter

by RAMBOO1990 ST4 Trending

No description provided

Details

Installs

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

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+PPackage 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