不喜欢广告? 无广告 今天

HJSON Formatter & Validator

数据开发人员
广告 移除?

或者

选项

Validation results will appear here.
广告 移除?

指导

HJSON Formatter & Validator

HJSON Formatter & Validator

Paste HJSON — the human-friendly variant of JSON that allows comments, unquoted keys and strings, multiline values, and trailing commas — and convert it to strict JSON instantly. The tool also runs the conversion in reverse: drop in strict JSON and get a cleaner HJSON version with unquoted keys for easier reading and editing.

Validation runs line-by-line as you type, so syntax errors surface immediately with line and column hints. Everything runs locally in your browser — no file upload, no server round-trip, no data leaving the page.

如何使用

  1. Paste HJSON or strict JSON into the input box, or upload a file.
  2. Pick a direction — HJSON → JSON to clean up a human-edited config, or JSON → HJSON to make a machine-generated JSON file friendlier to maintain.
  3. Choose your indent (2 spaces, 4 spaces, tab, or minified for JSON output).
  4. Optionally sort object keys alphabetically for stable diffs.
  5. 复制格式化后的输出,或将其下载为一个 .json.hjson 文件。

特征

  • Two-way conversion – HJSON to strict JSON and back, with error messages pinpointing the offending line.
  • Full HJSON syntax - #, //,并且 /* */ comments; unquoted keys; quoteless single-line strings; triple-quoted multiline strings with smart dedent; trailing and optional commas.
  • Braceless root objects – top-level key: value pairs without an outer { } are recognized as a root object.
  • Clean output – choose 2-space, 4-space, tab, or minified indentation; HJSON output unquotes identifier keys for cleaner diffs.
  • Stable ordering – optional alphabetical key sorting on nested objects so your formatted output diffs cleanly across runs.
  • Local & private – parsing and formatting happen entirely in your browser; nothing is uploaded.

When to Use HJSON Instead of JSON

HJSON shines for config files that humans edit by hand: build pipelines, deployment manifests, CLI tool settings, game configs, and anywhere you want the readability of YAML without YAML’s indentation gotchas. HJSON is a strict superset of JSON, so any valid JSON is already valid HJSON — you can adopt it gradually, file by file.

广告 移除?

For machine-to-machine data exchange (APIs, storage, network protocols), keep strict JSON: it has universal parser support and a smaller, less ambiguous grammar. Convert HJSON to JSON at build time or load time, and let humans keep editing the friendlier source.

常问问题

  1. What is HJSON and how does it differ from JSON?

    HJSON, short for Human JSON, is a relaxed variant of JSON designed for hand-edited configuration. It adds comments (#, //, /* */), allows quoteless keys, quoteless single-line strings, multiline strings with triple quotes, and trailing or optional commas. Strict JSON disallows all of those for the sake of unambiguous machine parsing. Because every valid JSON document is also a valid HJSON document, HJSON is a strict superset — you can adopt it incrementally.

  2. How does HJSON compare to JSON5, JSONC, and YAML?

    JSON5 also adds comments and trailing commas but keeps strings quoted and requires JavaScript-style identifier keys. JSONC (JSON with Comments) only adds // and /* */ comments. YAML is far more permissive but relies on significant whitespace, which is error-prone for deeply nested structures. HJSON sits between JSON5 and YAML: most of YAML's readability with brace-delimited structure, so a misplaced indent doesn't change semantics.

  3. Are HJSON multiline strings and YAML block scalars equivalent?

    They serve the same purpose but differ in mechanics. HJSON multiline strings are delimited by triple single quotes ('''), and the indentation of the closing ''' determines how all interior lines are dedented — making the block portable across nesting levels. YAML offers literal (|) and folded (>) block scalars with separate chomping indicators (-, +) for trailing newlines. HJSON's single style is simpler at the cost of less control over trailing whitespace.

  4. Does HJSON change how numbers, booleans, and null are parsed?

    No. Numbers (including integers, decimals, and scientific notation), booleans, and null follow the same lexical rules as JSON. The disambiguation rule is straightforward: if an unquoted value parses cleanly as a JSON number, true, false, or null, it is parsed as that primitive; otherwise it becomes a quoteless string that extends to the end of the line.

  5. Can comments be preserved when converting HJSON to JSON?

    Not in the standard sense — strict JSON has no comment grammar, so a faithful conversion must drop them. Some toolchains work around this by keeping the HJSON file as the source of truth and producing JSON only as a build artifact, or by storing comments under a sibling key like _comment. If preserving comments matters, treat HJSON as your editable source and regenerate JSON on demand rather than the other way around.

想要享受无广告的体验吗? 立即无广告

安装我们的扩展

将 IO 工具添加到您最喜欢的浏览器,以便即时访问和更快地搜索

添加 Chrome 扩展程序 添加 边缘延伸 添加 Firefox 扩展 添加 Opera 扩展

记分板已到达!

记分板 是一种有趣的跟踪您游戏的方式,所有数据都存储在您的浏览器中。更多功能即将推出!

广告 移除?
广告 移除?
广告 移除?

新闻角 包含技术亮点

参与其中

帮助我们继续提供有价值的免费工具

给我买杯咖啡
广告 移除?