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

Json​5​Formatter

by RAMBOO1990 ST4 Trending

No description provided

Details

Installs

  • Total 440
  • Win 168
  • Mac 224
  • Linux 48
Aug 12 Aug 11 Aug 10 Aug 9 Aug 8 Aug 7 Aug 6 Aug 5 Aug 4 Aug 3 Aug 2 Aug 1 Jul 31 Jul 30 Jul 29 Jul 28 Jul 27 Jul 26 Jul 25 Jul 24 Jul 23 Jul 22 Jul 21 Jul 20 Jul 19 Jul 18 Jul 17 Jul 16 Jul 15 Jul 14 Jul 13 Jul 12 Jul 11 Jul 10 Jul 9 Jul 8 Jul 7 Jul 6 Jul 5 Jul 4 Jul 3 Jul 2 Jul 1 Jun 30 Jun 29
Windows 2 17 9 3 3 11 9 7 11 11 6 4 5 6 9 16 11 4 6 16 5 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Mac 2 13 12 3 3 9 10 21 16 15 7 4 13 13 24 19 10 4 3 17 11 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Linux 0 2 4 0 2 5 7 2 2 1 0 2 2 4 4 1 3 1 3 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

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