{
  "slug": "json5-convert",
  "name": "gizza-ai/json5-convert",
  "version": "0.1.0",
  "title": "JSON5 / JSONC to JSON Converter — and Back — gizza.ai",
  "description": "Convert JSON5 or JSONC to strict JSON — strip // comments and trailing commas, quote keys — or turn plain JSON back into JSON5. Private, in-browser, free.",
  "tags": [
    "json5 to json",
    "jsonc to json",
    "json with comments",
    "remove json comments",
    "trailing comma",
    "unquoted keys",
    "json to json5",
    "tsconfig",
    "settings.json",
    "strict json"
  ],
  "category": "data",
  "urls": {
    "page": "https://gizza.ai/tools/json5-convert/",
    "markdown": "https://gizza.ai/tools/json5-convert/index.md",
    "descriptor": "https://gizza.ai/tools/json5-convert/tool.json",
    "deep_link_example": "https://gizza.ai/tools/json5-convert/?text=%7B%0A%20%20%2F%2F%20the%20dev%20server%20port%0A%20%20port%3A%208080%2C%0A%20%20hosts%3A%20%5B%27a%27%2C%20%27b%27%2C%5D%2C%0A%7D&direction=to-json&indent=2&sort_keys=true&nonfinite=null&quote_style=single&unquote_keys=true&trailing_commas=true"
  },
  "cli": "gizza tool json5-convert \"{\n  // the dev server port\n  port: 8080,\n  hosts: ['a', 'b',],\n}\"",
  "tool": {
    "description": "Convert JSON5 or JSONC (JSON with comments) to strict RFC 8259 JSON, or turn strict JSON back into JSON5. Reads the full JSON5 grammar: // and /* */ comments, trailing commas, unquoted identifier keys, single-quoted strings, escaped line continuations, \\x escapes, hexadecimal / leading-dot / trailing-dot / leading-plus numbers, and NaN / Infinity / -Infinity. Use direction='to-json' (default) to strip comments and normalize a tsconfig.json or VS Code settings.json for a strict parser; direction='to-json5' to emit unquoted keys and single quotes; direction='auto' to convert whichever way the input is not. indent picks 2/4/tab spaces or 'minify'; sort_keys=true sorts keys at every level; nonfinite says how NaN/Infinity become strict JSON (null, string or error). Object key order is preserved and repeated keys collapse last-wins. Parse errors report the line and column. Comments carry no data and are always dropped — output is data only.",
    "parameters": {
      "additionalProperties": false,
      "properties": {
        "direction": {
          "default": "to-json",
          "description": "Which way to convert. 'to-json' (default) emits strict RFC 8259 JSON — comments and trailing commas are dropped, keys and strings become double-quoted. 'to-json5' emits JSON5 — unquoted keys, single quotes, optional trailing commas. 'auto' emits strict JSON when the input used any JSON5-only syntax, and JSON5 when the input was already strict JSON.",
          "enum": [
            "to-json",
            "to-json5",
            "auto"
          ],
          "type": "string"
        },
        "indent": {
          "default": "2",
          "description": "Output formatting: '2' (default) or '4' spaces of indentation per level, 'tab' for tab indentation, or 'minify' for a single compact line.",
          "enum": [
            "2",
            "4",
            "tab",
            "minify"
          ],
          "type": "string"
        },
        "nonfinite": {
          "default": "null",
          "description": "What to do with the JSON5 literals NaN, Infinity and -Infinity when writing strict JSON, which cannot express them: 'null' (default, what JSON.stringify does), 'string' to emit them as \"NaN\"/\"Infinity\"/\"-Infinity\", or 'error' to refuse the conversion. Ignored when direction='to-json5', which keeps the literals as-is.",
          "enum": [
            "null",
            "string",
            "error"
          ],
          "type": "string"
        },
        "quote_style": {
          "default": "single",
          "description": "Quote character for strings and quoted keys in JSON5 output: 'single' (default, the JSON5 house style) or 'double'. Ignored when writing strict JSON, which always uses double quotes.",
          "enum": [
            "single",
            "double"
          ],
          "type": "string"
        },
        "sort_keys": {
          "default": false,
          "description": "When true, sort every object's keys alphabetically (by Unicode code point) at every nesting level. Default false, which keeps the input's key order.",
          "type": "boolean"
        },
        "text": {
          "description": "The JSON5, JSONC or strict JSON text to convert. JSON5 input may use // and /* */ comments, trailing commas, unquoted keys, single quotes, hex numbers and NaN/Infinity. Example: {port: 8080, /* dev */ hosts: ['a','b',],}",
          "type": "string"
        },
        "trailing_commas": {
          "default": false,
          "description": "When true, JSON5 output adds a trailing comma after the last element of every non-empty array and object, so later diffs touch one line. Default false. Ignored when writing strict JSON.",
          "type": "boolean"
        },
        "unquote_keys": {
          "default": true,
          "description": "When true (default), JSON5 output leaves object keys unquoted where they are valid ASCII identifiers (letters, digits, _ and $, not starting with a digit); other keys stay quoted. Set false to quote every key. Ignored when writing strict JSON.",
          "type": "boolean"
        }
      },
      "required": [
        "text"
      ],
      "type": "object"
    }
  }
}