[{"data":1,"prerenderedAt":1206},["ShallowReactive",2],{"blog-batch-en-json-comments":3},[4],{"id":5,"title":6,"author":7,"body":8,"category":1184,"date":1185,"description":1186,"draft":1187,"extension":1188,"h1":15,"image":1189,"lastmod":1185,"locales":1190,"meta":1192,"navigation":1193,"path":1194,"promo":1195,"seo":1199,"stem":1200,"tags":1201,"__hash__":1205},"blog\u002Fen\u002Fblog\u002Fjson-comments.md","Comments in JSON: Why Not Allowed & What to Use","JSON Toolbox Team",{"type":9,"value":10,"toc":1148},"minimark",[11,16,33,47,52,59,62,84,87,97,102,110,114,121,124,127,141,144,148,151,157,227,230,238,242,245,250,253,261,280,285,293,298,309,315,319,330,334,342,346,354,368,372,375,379,391,394,397,403,407,413,448,456,459,463,469,486,489,493,670,676,680,687,693,710,717,724,728,741,744,750,764,771,774,796,800,804,807,815,823,826,830,836,844,847,851,869,872,909,916,950,953,957,960,977,985,989,993,1010,1014,1017,1021,1034,1037,1044,1053,1057,1066,1070,1073,1077,1088,1092,1139,1142],[12,13,15],"h1",{"id":14},"comments-in-json-why-theyre-not-allowed-and-what-to-use-instead","Comments in JSON: Why They're Not Allowed and What to Use Instead",[17,18,19,20,24,25,28,29,32],"p",{},"You paste a config file into your code, call ",[21,22,23],"code",{},"JSON.parse()",", and get ",[21,26,27],{},"SyntaxError: Unexpected token \u002F",". Everything looks correct — except for the ",[21,30,31],{},"\u002F\u002F TODO: bump this after launch"," line at the top.",[17,34,35,36,39,40,39,43,46],{},"Standard JSON has no comment syntax. Not ",[21,37,38],{},"\u002F\u002F",", not ",[21,41,42],{},"\u002F* *\u002F",[21,44,45],{},"#",". This guide explains why, what actually happens when you add comments, the workarounds that keep your file valid, and how JSONC, JSON5, and HJSON fit in.",[48,49,51],"h2",{"id":50},"can-you-put-comments-in-a-json-file","Can you put comments in a JSON file?",[17,53,54,58],{},[55,56,57],"strong",{},"No."," Standard JSON does not allow comments anywhere in the document — not inside the top-level object or array, and not outside it either.",[17,60,61],{},"Both current JSON specifications define a grammar with no comment tokens:",[63,64,65,76],"ul",{},[66,67,68,75],"li",{},[69,70,74],"a",{"href":71,"rel":72},"https:\u002F\u002Fwww.rfc-editor.org\u002Frfc\u002Frfc8259",[73],"nofollow","RFC 8259"," (The JavaScript Object Notation Data Interchange Format)",[66,77,78,83],{},[69,79,82],{"href":80,"rel":81},"https:\u002F\u002Fwww.ecma-international.org\u002Fpublications-and-standards\u002Fstandards\u002Fecma-404\u002F",[73],"ECMA-404"," (The JSON Data Interchange Syntax)",[17,85,86],{},"A file that contains comments is not valid JSON, even when every other character is perfect:",[88,89,95],"pre",{"className":90,"code":92,"language":93,"meta":94},[91],"language-jsonc","{\n  \u002F\u002F Display name shown in the UI\n  \"name\": \"Ada\",\n  \"age\": 30\n}\n","jsonc","",[21,96,92],{"__ignoreMap":94},[17,98,99,101],{},[21,100,23],{}," on that string throws:",[88,103,108],{"className":104,"code":106,"language":107,"meta":94},[105],"language-text","SyntaxError: Unexpected token \u002F in JSON at position 4\n","text",[21,109,106],{"__ignoreMap":94},[48,111,113],{"id":112},"why-doesnt-json-allow-comments","Why doesn't JSON allow comments?",[17,115,116,117,120],{},"JSON was designed as a ",[55,118,119],{},"data interchange format",", not as a configuration language or a programming language. Keeping the grammar tiny was a deliberate goal: a smaller grammar means more parsers, in more languages, that all agree on what a document means.",[17,122,123],{},"Douglas Crockford, who popularized JSON, has described removing comments from an early draft after seeing people use them to carry parsing directives — instructions that changed how a document should be interpreted. Different implementations then read the same file differently, which defeated the point of a shared interchange format. Dropping comments removed the ambiguity.",[17,125,126],{},"The trade-off is intentional and still visible today:",[63,128,129,135],{},[66,130,131,134],{},[55,132,133],{},"Gained:"," a format that is trivial to parse, easy to implement, and highly interoperable.",[66,136,137,140],{},[55,138,139],{},"Lost:"," any way to document a JSON file inline.",[17,142,143],{},"That trade-off is why comments are the single most-requested JSON \"missing feature\", and why the practical answers are all workarounds or supersets.",[48,145,147],{"id":146},"what-happens-if-you-add-comments-to-a-json-file","What happens if you add comments to a JSON file?",[17,149,150],{},"Every strict parser rejects the file. The error differs by tool, but the outcome is the same:",[88,152,155],{"className":153,"code":154,"language":93,"meta":94},[91],"\u002F\u002F Leading comment (invalid)\n{\n  \"name\": \"Ada\", \u002F\u002F inline comment (invalid)\n  \"users\": [\n    \u002F* { \"id\": 1, \"name\": \"Ada\" } *\u002F\n    { \"id\": 2, \"name\": \"Lin\" }\n  ]\n}\n",[21,156,154],{"__ignoreMap":94},[158,159,160,173],"table",{},[161,162,163],"thead",{},[164,165,166,170],"tr",{},[167,168,169],"th",{},"Parser",[167,171,172],{},"Typical result",[174,175,176,188,201,214],"tbody",{},[164,177,178,184],{},[179,180,181,183],"td",{},[21,182,23],{}," (JavaScript)",[179,185,186],{},[21,187,27],{},[164,189,190,196],{},[179,191,192,195],{},[21,193,194],{},"json.loads()"," (Python)",[179,197,198],{},[21,199,200],{},"json.decoder.JSONDecodeError",[164,202,203,209],{},[179,204,205,208],{},[21,206,207],{},"jq"," (CLI)",[179,210,211],{},[21,212,213],{},"parse error: Invalid literal",[164,215,216,222],{},[179,217,218,221],{},[21,219,220],{},"JsonDocument.Parse()"," (.NET)",[179,223,224],{},[21,225,226],{},"JsonException",[17,228,229],{},"The moment comments go in, the file stops being JSON in the RFC sense. Depending on which extra syntax you used, it is now JSONC, JSON5, HJSON, or an unnamed custom variant — and only a parser for that variant can read it.",[17,231,232,233,237],{},"If your JSON is failing to parse for reasons beyond comments, see ",[69,234,236],{"href":235},"\u002Fblog\u002Fjson-parse-error-debug","JSON Parse Failed: 10 Common API Errors and How to Debug Them",".",[48,239,241],{"id":240},"how-to-comment-in-a-json-file-workarounds-that-stay-valid","How to comment in a JSON file: workarounds that stay valid",[17,243,244],{},"If the file must remain strict JSON — because an API, a package manager, or a third-party tool reads it — you have two realistic options.",[246,247,249],"h3",{"id":248},"option-1-use-a-dedicated-comment-key","Option 1: Use a dedicated comment key",[17,251,252],{},"Reserve a key for documentation and put your notes in it:",[88,254,259],{"className":255,"code":257,"language":258,"meta":94},[256],"language-json","{\n  \"_comment\": \"Event schema for the analytics pipeline. Versioned separately from the API.\",\n  \"version\": \"1.2.0\",\n  \"fields\": [\n    {\n      \"name\": \"user_id\",\n      \"type\": \"string\",\n      \"_comment\": \"Primary key. Must be unique per tenant.\"\n    }\n  ]\n}\n","json",[21,260,257],{"__ignoreMap":94},[17,262,263,264,267,268,267,271,267,273,276,277,237],{},"Common key names include ",[21,265,266],{},"_comment",", ",[21,269,270],{},"__comment__",[21,272,38],{},[21,274,275],{},"description",", and ",[21,278,279],{},"doc",[17,281,282],{},[55,283,284],{},"Pros:",[63,286,287,290],{},[66,288,289],{},"The file stays valid standard JSON; nothing special is required to read it.",[66,291,292],{},"Comments travel with the data, which is useful for example payloads and self-describing schemas.",[17,294,295],{},[55,296,297],{},"Cons:",[63,299,300,303,306],{},[66,301,302],{},"Comments become part of the data model. Anything iterating over keys will see them.",[66,304,305],{},"Consumers must ignore the key. If you serve this JSON from an API, the key ships to clients.",[66,307,308],{},"Heavy use clutters the structure.",[17,310,311,312,237],{},"This pattern works well for fixtures, sample payloads, and schema-ish documents. It is a poor fit for hot paths where payload size matters, and for documents validated with ",[21,313,314],{},"additionalProperties: false",[246,316,318],{"id":317},"option-2-keep-the-documentation-outside-the-file","Option 2: Keep the documentation outside the file",[17,320,321,322,325,326,329],{},"Keep ",[21,323,324],{},"config.json"," strict and describe it elsewhere — a ",[21,327,328],{},"README.md",", a JSON Schema file, or your docs site.",[17,331,332],{},[55,333,284],{},[63,335,336,339],{},[66,337,338],{},"The runtime file stays minimal and strictly valid.",[66,340,341],{},"Documentation can be richer: Markdown, examples, diagrams, change history.",[17,343,344],{},[55,345,297],{},[63,347,348,351],{},[66,349,350],{},"Documentation can drift from the data unless something enforces the link.",[66,352,353],{},"Requires discipline to keep both in sync.",[17,355,356,357,362,363,367],{},"For public APIs and shared data pipelines, this is usually the right choice. A ",[69,358,361],{"href":359,"rel":360},"https:\u002F\u002Fjson-schema.org\u002Fdocs",[73],"JSON Schema"," is the strongest version of this approach: it documents required fields, types, and ranges in a machine-checkable format. See ",[69,364,366],{"href":365},"\u002Fblog\u002Fjson-validation-syntax-vs-schema","JSON Validation Explained: Syntax Checks vs JSON Schema Validation"," for how the layers fit together.",[48,369,371],{"id":370},"jsonc-json5-and-hjson-formats-that-allow-comments","JSONC, JSON5, and HJSON: formats that allow comments",[17,373,374],{},"When you need real comments, switch to a superset. Three come up in practice.",[246,376,378],{"id":377},"jsonc-json-with-comments","JSONC — JSON with Comments",[17,380,381,384,385,387,388,390],{},[55,382,383],{},"JSONC"," is the smallest step away from strict JSON: it adds ",[21,386,38],{}," line comments and ",[21,389,42],{}," block comments and leaves everything else alone. Keys are still quoted, strings still use double quotes, and numbers still follow the JSON grammar.",[17,392,393],{},"There is no formal JSONC specification — the name is a convention used by tools that accept \"JSON with comments\". Trailing commas are not part of the definition, but some parsers tolerate them.",[17,395,396],{},"Typical use: editor and tool configuration, where humans edit the file by hand and comments explain non-obvious choices.",[88,398,401],{"className":399,"code":400,"language":93,"meta":94},[91],"{\n  \u002F\u002F Matches the deploy target in CI\n  \"region\": \"eu-central-1\",\n  \u002F* Raise together with the API gateway timeout *\u002F\n  \"timeoutMs\": 30000\n}\n",[21,402,400],{"__ignoreMap":94},[246,404,406],{"id":405},"json5-json-for-humans","JSON5 — JSON for Humans",[17,408,409,412],{},[55,410,411],{},"JSON5"," is a much more relaxed superset aimed at hand-written files. It supports:",[63,414,415,423,426,429,432,445],{},[66,416,417,419,420,422],{},[21,418,38],{}," and ",[21,421,42],{}," comments",[66,424,425],{},"Trailing commas in objects and arrays",[66,427,428],{},"Unquoted keys (when they are valid identifiers)",[66,430,431],{},"Single-quoted strings",[66,433,434,435,267,438,267,441,444],{},"Extra number forms: hexadecimal, leading ",[21,436,437],{},"+",[21,439,440],{},"NaN",[21,442,443],{},"Infinity",", leading and trailing decimal points",[66,446,447],{},"Line continuations in strings",[88,449,454],{"className":450,"code":452,"language":453,"meta":94},[451],"language-json5","{\n  \u002F\u002F User profile in JSON5\n  name: 'Ada',\n  age: 30,\n  roles: [\n    'admin',\n    'editor', \u002F\u002F trailing comma is fine\n  ],\n}\n","json5",[21,455,452],{"__ignoreMap":94},[17,457,458],{},"JSON5 is comfortable to write and further from strict JSON than JSONC. Nothing that reads strict JSON is guaranteed to read JSON5.",[246,460,462],{"id":461},"hjson-human-json","HJSON — Human JSON",[17,464,465,468],{},[55,466,467],{},"HJSON"," pushes furthest toward human readability:",[63,470,471,480,483],{},[66,472,473,474,267,476,276,478],{},"Comments with ",[21,475,45],{},[21,477,38],{},[21,479,42],{},[66,481,482],{},"Quoteless keys and string values in most cases",[66,484,485],{},"Commas are optional — a newline is usually enough to separate members",[17,487,488],{},"It has the smallest ecosystem of the three and shows up mostly in niche configuration tooling.",[246,490,492],{"id":491},"comparison","Comparison",[158,494,495,511],{},[161,496,497],{},[164,498,499,502,505,507,509],{},[167,500,501],{},"Feature",[167,503,504],{},"JSON (RFC 8259)",[167,506,383],{},[167,508,411],{},[167,510,467],{},[174,512,513,529,543,557,572,585,597,611,637,653],{},[164,514,515,519,522,525,527],{},[179,516,517,422],{},[21,518,38],{},[179,520,521],{},"No",[179,523,524],{},"Yes",[179,526,524],{},[179,528,524],{},[164,530,531,535,537,539,541],{},[179,532,533,422],{},[21,534,42],{},[179,536,521],{},[179,538,524],{},[179,540,524],{},[179,542,524],{},[164,544,545,549,551,553,555],{},[179,546,547,422],{},[21,548,45],{},[179,550,521],{},[179,552,521],{},[179,554,521],{},[179,556,524],{},[164,558,559,562,564,567,569],{},[179,560,561],{},"Trailing commas",[179,563,521],{},[179,565,566],{},"Depends on the parser",[179,568,524],{},[179,570,571],{},"Not applicable — commas are optional",[164,573,574,577,579,581,583],{},[179,575,576],{},"Unquoted keys",[179,578,521],{},[179,580,521],{},[179,582,524],{},[179,584,524],{},[164,586,587,589,591,593,595],{},[179,588,431],{},[179,590,521],{},[179,592,521],{},[179,594,524],{},[179,596,524],{},[164,598,599,602,604,606,608],{},[179,600,601],{},"Extra number forms",[179,603,521],{},[179,605,521],{},[179,607,524],{},[179,609,610],{},"Limited",[164,612,613,616,619,622,630],{},[179,614,615],{},"Specification",[179,617,618],{},"RFC 8259 \u002F ECMA-404",[179,620,621],{},"De facto convention",[179,623,624,629],{},[69,625,628],{"href":626,"rel":627},"https:\u002F\u002Fjson5.org\u002F",[73],"json5.org"," spec",[179,631,632,629],{},[69,633,636],{"href":634,"rel":635},"https:\u002F\u002Fhjson.github.io\u002F",[73],"hjson.github.io",[164,638,639,642,645,648,651],{},[179,640,641],{},"Main goal",[179,643,644],{},"Data interchange",[179,646,647],{},"Config with comments",[179,649,650],{},"Human-friendly config",[179,652,650],{},[164,654,655,658,661,664,667],{},[179,656,657],{},"Typical use",[179,659,660],{},"APIs, data files",[179,662,663],{},"Editor configs",[179,665,666],{},"Hand-written configs",[179,668,669],{},"Niche configs",[17,671,672,675],{},[55,673,674],{},"Rule of thumb:"," if you only need comments, use JSONC. It keeps the file one comment-strip away from strict JSON. Reach for JSON5 when you also want a JavaScript-like syntax, and HJSON only when its specific readability rules are what you want.",[48,677,679],{"id":678},"why-vs-codes-settingsjson-allows-comments","Why VS Code's settings.json allows comments",[17,681,682,683,686],{},"Open VS Code's ",[21,684,685],{},"settings.json"," and comments work fine:",[88,688,691],{"className":689,"code":690,"language":93,"meta":94},[91],"\u002F\u002F settings.json — this file is JSONC, not strict JSON\n{\n  \"editor.fontSize\": 14,\n  \u002F\u002F The minimap is distracting on wide screens\n  \"editor.minimap.enabled\": false\n}\n",[21,692,690],{"__ignoreMap":94},[17,694,695,696,267,698,701,702,705,706,709],{},"The file is not being read as strict JSON. VS Code treats ",[21,697,685],{},[21,699,700],{},"keybindings.json",", and similar files as ",[55,703,704],{},"JSON with comments",", and its JSON language service parses them in a mode that allows comments. TypeScript does the same for ",[21,707,708],{},"tsconfig.json",", which is why comments and trailing commas are accepted there too.",[17,711,712,713,716],{},"The confusing part is naming: the extension is ",[21,714,715],{},".json",", the docs say \"JSON\", and comments still work — because the consumer opted into a superset. Copy that same content into a strict parser and it fails immediately.",[17,718,719,720,723],{},"This is the general pattern: ",[55,721,722],{},"comments are a property of the reader, not of the file."," A file with comments parses only when the tool on the other end agreed to accept them.",[48,725,727],{"id":726},"converting-jsonc-to-json-why-a-regex-is-not-enough","Converting JSONC to JSON: why a regex is not enough",[17,729,730,731,734,735,419,738,237],{},"Eventually a JSONC file has to become strict JSON — a CI tool that rejects comments, an API request body, or a library that only accepts ",[21,732,733],{},"application\u002Fjson",". The tempting one-liner is a regular expression that deletes ",[21,736,737],{},"\u002F\u002F…",[21,739,740],{},"\u002F*…*\u002F",[17,742,743],{},"It works until it doesn't:",[88,745,748],{"className":746,"code":747,"language":93,"meta":94},[91],"{\n  \"url\": \"https:\u002F\u002Fexample.com\u002F\u002Fassets\",\n  \"pattern\": \"\u002F* match everything *\u002F\",\n  \"note\": \"Use \u002F\u002F for comments in code, never in JSON\"\n}\n",[21,749,747],{"__ignoreMap":94},[17,751,752,753,755,756,759,760,763],{},"A regex that removes ",[21,754,38],{}," to end of line turns the URL into ",[21,757,758],{},"\"https:\u002F\u002Fexample.com\""," and empties the note. A regex that removes ",[21,761,762],{},"\u002F* … *\u002F"," destroys the pattern. The output is silently wrong, and it may still parse — which makes it worse than an error.",[17,765,766,767,770],{},"The root problem: ",[55,768,769],{},"comment markers and string content can be the same characters."," Only a scanner that tracks whether it is inside a quoted string can tell them apart.",[17,772,773],{},"The safe procedure is:",[775,776,777,780,790,793],"ol",{},[66,778,779],{},"Walk the input character by character (or parse it into an AST), copying quoted strings verbatim.",[66,781,782,783,786,787,237],{},"Drop comment tokens and, if you want them gone, trailing commas before ",[21,784,785],{},"}"," or ",[21,788,789],{},"]",[66,791,792],{},"Parse the cleaned text with a strict JSON parser to confirm the result is valid.",[66,794,795],{},"Report a line and column for anything that is not valid.",[48,797,799],{"id":798},"practical-options-for-working-with-json-with-comments","Practical options for working with JSON with comments",[246,801,803],{"id":802},"_1-parse-jsonc-directly-in-your-own-code","1. Parse JSONC directly in your own code",[17,805,806],{},"If you control the runtime, the cleanest fix is to let the reader accept comments, and keep comments in the source file:",[88,808,813],{"className":809,"code":811,"language":812,"meta":94},[810],"language-js","import { parse } from 'jsonc-parser'\n\n\u002F\u002F Throws on JSONC syntax errors, returns a normal JS object otherwise.\nconst config = parse(await fs.readFile('config.jsonc', 'utf8'))\n","js",[21,814,811],{"__ignoreMap":94},[88,816,821],{"className":817,"code":819,"language":820,"meta":94},[818],"language-python","import json5\n\nwith open(\"config.json5\", \"r\", encoding=\"utf-8\") as f:\n    config = json5.load(f)\n","python",[21,822,819],{"__ignoreMap":94},[17,824,825],{},"Best for configs that humans edit and your own application consumes.",[246,827,829],{"id":828},"_2-strip-comments-as-a-build-step","2. Strip comments as a build step",[17,831,832,833,835],{},"Keep JSONC in the repository and emit ",[21,834,715],{}," during the build, so the runtime never sees comments:",[88,837,842],{"className":838,"code":840,"language":841,"meta":94},[839],"language-bash","npm install --save-dev strip-json-comments\n","bash",[21,843,840],{"__ignoreMap":94},[17,845,846],{},"Then convert before packaging or deploying. Developers get comments; deployments get strict JSON. This is the most robust setup for pipelines with mixed tooling.",[246,848,850],{"id":849},"_3-convert-jsonc-to-json-in-your-browser","3. Convert JSONC to JSON in your browser",[17,852,853,854,858,859,267,862,864,865,868],{},"For one-off conversions, use the ",[69,855,857],{"href":856},"\u002Ftools\u002Fconvert\u002Fjsonc-to-json","JSONC to JSON Converter",". Paste JSONC or open a ",[21,860,861],{},".jsonc",[21,863,715],{},", or ",[21,866,867],{},".txt"," file, and it produces standard JSON.",[17,870,871],{},"What it does:",[63,873,874,888,898,901,904],{},[66,875,876,877,879,880,882,883,786,885,887],{},"Removes ",[21,878,38],{}," line comments, ",[21,881,42],{}," block comments, and trailing commas before ",[21,884,785],{},[21,886,789],{},". Each has its own checkbox, and all three are on by default.",[66,889,890,891,893,894,897],{},"Scans the input character by character and copies quoted strings verbatim, so ",[21,892,38],{}," inside ",[21,895,896],{},"\"https:\u002F\u002Fexample.com\u002Fa\u002F\u002Fb\""," survives.",[66,899,900],{},"Parses the cleaned result as strict JSON and reports the line and column of any error, including unclosed block comments and commas with no value before them.",[66,902,903],{},"Shows how many comments and trailing commas were removed.",[66,905,906,907,237],{},"Outputs JSON with two-space, four-space, or minified indentation; you can copy the result or download it as ",[21,908,715],{},[17,910,911,912,915],{},"What it does ",[55,913,914],{},"not"," do:",[63,917,918,929,935,944],{},[66,919,920,923,924,276,926,928],{},[55,921,922],{},"It does not parse JSON5."," Unquoted keys, single-quoted strings, hexadecimal numbers, ",[21,925,440],{},[21,927,443],{}," are reported as syntax errors.",[66,930,931,934],{},[55,932,933],{},"It does not preserve comments."," Standard JSON has no comment syntax, so no tool can keep them in the output. Keep your original file.",[66,936,937,940,941,943],{},[55,938,939],{},"It does not validate configuration schemas."," Converting a ",[21,942,708],{}," checks JSON syntax only — not TypeScript, ESLint, or Webpack semantics.",[66,945,946,949],{},[55,947,948],{},"It is not tuned for very large files."," Rendering depends on browser memory and size; for huge files, a local parser or a build-time conversion is a better fit.",[17,951,952],{},"Like every tool on this site, the conversion runs in your browser; the tool does not upload your JSONC.",[246,954,956],{"id":955},"_4-consider-yaml-or-toml-for-comment-heavy-config","4. Consider YAML or TOML for comment-heavy config",[17,958,959],{},"If a file needs extensive explanation, multi-line strings, or anchors and references, JSON is the wrong container.",[63,961,962,971],{},[66,963,964,967,968,970],{},[55,965,966],{},"YAML"," is the default for CI pipelines, Kubernetes manifests, and many deployment tools, and its ",[21,969,45],{}," comments are first-class.",[66,972,973,976],{},[55,974,975],{},"TOML"," is designed for hand-edited config and reads clearly, with comments throughout.",[17,978,979,980,984],{},"Keep JSON for data interchange and APIs, and use YAML or TOML where humans are the primary audience. When you do need to move between them, the ",[69,981,983],{"href":982},"\u002Ftools\u002Fconvert\u002Fjson-to-yaml","JSON to YAML Converter"," handles the JSON-to-YAML direction.",[48,986,988],{"id":987},"faq","FAQ",[246,990,992],{"id":991},"can-you-make-comments-outside-the-brackets-in-json","Can you make comments outside the brackets in JSON?",[17,994,995,996,999,1000,1002,1003,267,1005,864,1007,1009],{},"No. Standard JSON has no comment syntax anywhere in a document — before the top-level ",[21,997,998],{},"{",", inside it, or after the closing ",[21,1001,785],{},". Any ",[21,1004,38],{},[21,1006,42],{},[21,1008,45],{}," makes the file invalid JSON.",[246,1011,1013],{"id":1012},"is-jsonc-valid-json","Is JSONC valid JSON?",[17,1015,1016],{},"Strictly, no. All valid JSON is valid JSONC, but JSONC that actually contains comments is not valid JSON under RFC 8259. Tools that advertise JSONC support have opted into a superset.",[246,1018,1020],{"id":1019},"how-do-i-remove-comments-from-a-json-file","How do I remove comments from a JSON file?",[17,1022,1023,1024,786,1027,1030,1031,1033],{},"Use a parser that understands JSONC rather than a search-and-replace. In a build pipeline, ",[21,1025,1026],{},"strip-json-comments",[21,1028,1029],{},"jsonc-parser"," will do it. For a one-off file, paste it into the ",[69,1032,857],{"href":856},", which removes comments and trailing commas while leaving string content intact, then validates the result.",[17,1035,1036],{},"Avoid regex-based stripping on files you did not write. Corrupting a URL or a pattern silently is worse than an error you can see.",[246,1038,1040,1041,1043],{"id":1039},"can-i-use-_comment-keys-in-production-json","Can I use ",[21,1042,266],{}," keys in production JSON?",[17,1045,1046,1047,1049,1050,1052],{},"Yes — they are ordinary keys, so the file stays valid. Just make sure consumers ignore them, that they do not leak into responses or logs where they are noise, and that any schema validation accounts for them. With ",[21,1048,314],{},", an undeclared ",[21,1051,266],{}," key is rejected.",[246,1054,1056],{"id":1055},"should-i-use-jsonc-or-json5","Should I use JSONC or JSON5?",[17,1058,1059,1060,1062,1063,1065],{},"Use ",[55,1061,383],{}," if comments are the only thing you need. It stays close to strict JSON, so a comment strip is all that separates your file from something any parser accepts. Use ",[55,1064,411],{}," when you also want unquoted keys, trailing commas, and single-quoted strings in hand-written files.",[246,1067,1069],{"id":1068},"will-removing-comments-break-my-configuration","Will removing comments break my configuration?",[17,1071,1072],{},"Removing comments does not change the values a parser reads, but it does remove information humans need. Keep the original JSONC file and generate strict JSON only where it is required — a CI step, an API call, or a consumer that rejects comments.",[246,1074,1076],{"id":1075},"why-does-my-api-reject-json-with-comments-while-my-editor-accepts-it","Why does my API reject JSON with comments while my editor accepts it?",[17,1078,1079,1080,419,1082,1084,1085,1087],{},"Because they are different readers. Editors such as VS Code parse ",[21,1081,685],{},[21,1083,708],{}," as JSONC. An API that declares ",[21,1086,733],{}," is almost always using a strict parser, which rejects comments by design. This applies to request bodies too: never send commented JSON to an endpoint that expects JSON.",[48,1089,1091],{"id":1090},"whats-next","What's Next?",[63,1093,1094,1102,1112,1120,1128],{},[66,1095,1096,1099,1100,237],{},[55,1097,1098],{},"Have a JSONC file to clean up?"," Strip comments, block comments, and trailing commas with the ",[69,1101,857],{"href":856},[66,1103,1104,1107,1108,237],{},[55,1105,1106],{},"Working with standard JSON?"," Format, validate, and minify it in the ",[69,1109,1111],{"href":1110},"\u002Ftools\u002Fformat\u002Fjson-editor","JSON Editor",[66,1113,1114,1117,1118,237],{},[55,1115,1116],{},"Config needs more than comments?"," Convert to YAML with the ",[69,1119,983],{"href":982},[66,1121,1122,1125,1126,237],{},[55,1123,1124],{},"Still hitting parse errors?"," Read ",[69,1127,236],{"href":235},[66,1129,1130,1133,1134,1138],{},[55,1131,1132],{},"Designing an API?"," See ",[69,1135,1137],{"href":1136},"\u002Fblog\u002Fjson-best-practices","JSON Best Practices in Real Projects"," for response structure, validation, and security.",[1140,1141],"hr",{},[17,1143,1144],{},[1145,1146,1147],"em",{},"All tools on JSON Toolbox run entirely in your browser. Your data never leaves your device.",{"title":94,"searchDepth":1149,"depth":1149,"links":1150},2,[1151,1152,1153,1154,1159,1165,1166,1167,1173,1183],{"id":50,"depth":1149,"text":51},{"id":112,"depth":1149,"text":113},{"id":146,"depth":1149,"text":147},{"id":240,"depth":1149,"text":241,"children":1155},[1156,1158],{"id":248,"depth":1157,"text":249},3,{"id":317,"depth":1157,"text":318},{"id":370,"depth":1149,"text":371,"children":1160},[1161,1162,1163,1164],{"id":377,"depth":1157,"text":378},{"id":405,"depth":1157,"text":406},{"id":461,"depth":1157,"text":462},{"id":491,"depth":1157,"text":492},{"id":678,"depth":1149,"text":679},{"id":726,"depth":1149,"text":727},{"id":798,"depth":1149,"text":799,"children":1168},[1169,1170,1171,1172],{"id":802,"depth":1157,"text":803},{"id":828,"depth":1157,"text":829},{"id":849,"depth":1157,"text":850},{"id":955,"depth":1157,"text":956},{"id":987,"depth":1149,"text":988,"children":1174},[1175,1176,1177,1178,1180,1181,1182],{"id":991,"depth":1157,"text":992},{"id":1012,"depth":1157,"text":1013},{"id":1019,"depth":1157,"text":1020},{"id":1039,"depth":1157,"text":1179},"Can I use _comment keys in production JSON?",{"id":1055,"depth":1157,"text":1056},{"id":1068,"depth":1157,"text":1069},{"id":1075,"depth":1157,"text":1076},{"id":1090,"depth":1149,"text":1091},"json_tools","2026-09-29T00:00:00.000Z","JSON doesn't allow comments. Learn why, plus safe workarounds: JSONC, JSON5, `_comment` keys, and converting JSONC to standard JSON in your browser.",false,"md","\u002Fblog\u002Fcover\u002Fen\u002Fjson-comments-cover.svg",[1191],"en",{},true,"\u002Fen\u002Fblog\u002Fjson-comments",{"slug":1196,"text":1197,"btn":1198},"jsonc-to-json","Need to strip comments from a JSONC file?","Open JSONC to JSON Converter",{"title":6,"description":1186},"en\u002Fblog\u002Fjson-comments",[1202,383,411,1203,1204],"JSON","Configuration","Best Practices","jOTiT98JeRCxwOVLoAepb9wILWSI_h9ezwPpviW_ZE0",1791273859785]