JSON5 File: What Is .json5?

A plain text data file: JSON that people can comment, read and edit by hand.

A .json5 file holds settings or structured data in JSON5, a superset of JSON that borrows comments, unquoted keys, single quotes and trailing commas from ECMAScript 5.1. Any text editor opens it, and nothing in it runs when you do.

Below you will find an annotated sample, steps for Windows, macOS and Linux, editor support, media type facts, tested conversion and validation commands, server settings, and fixes for the errors that make a program reject the file.

An open file drawer feeding a .json5 settings file into a text editor, a converter and a validator

TL;DR: It is text. Open it in any editor. It is not strict JSON, so a plain JSON parser will reject most real JSON5 files. Convert one with npx json5 -s 2 file.json5 (comments are lost), check one with npx json5 -v file.json5, and serve it as application/json5, a widely used but unregistered media type.

Document icon

What the File Is

JSON5 began in 2012 as an extension of JSON meant to be easier to write and maintain by hand, mainly for configuration files. The project README says it is not intended for machine-to-machine communication. The specification, version 1.0.0 from March 2018, describes itself as a proposed extension to JSON. Every valid JSON document is also a valid JSON5 document, but the reverse is not true.

PropertyValue
Filename extension.json5
ContentPlain text; one value, usually an object in braces
Based onJSON, plus syntax taken from ECMAScript 5.1
Specification1.0.0, March 2018
Media type in common useapplication/json5 (not registered with IANA)
Executable?No. A parser reads it as data; there are no functions or expressions
GitHub language nameJSON5, matched by the .json5 extension (Linguist)

Receiving one usually means a build tool, an app or a game mod stores its settings that way. Read the file name and the top few keys first: they normally identify the program, and the table of common programs below lists the usual suspects. A safe file can still contain secrets such as API keys, so check the contents before you forward it.

Do not "open" it by evaluating it as JavaScript. The syntax looks like a JavaScript object, but feeding an unknown file to eval runs whatever code it holds. Use a parser. See the security guide.

Code file icon

A Sample .json5 File

This file, saved as server.json5, parses with version 2.2.3 of the reference JavaScript library. It is used for every command on this page.

// server.json5 - settings for a small web service { name: 'inventory-api', port: 8080, /* Hex is handy for permission masks. */ fileMode: 0x1A4, timeoutSeconds: 2.5, retryBackoff: .25, maxPayload: +1048576, rateLimit: Infinity, banner: 'Inventory service \ ready', hosts: [ 'api.example.com', 'backup.example.com', // trailing comma is fine ], }
In the sampleWhat it meansAllowed in JSON?
// and /* */Comments, ignored by the parserNo
name:Key without quotes; it must be a valid identifier nameNo
'inventory-api'Single-quoted stringNo
0x1A4Hexadecimal number, decimal 420No
.25Leading decimal pointNo
+1048576Explicit plus signNo
InfinityIEEE 754 infinity; NaN is allowed tooNo
Backslash at end of a lineThe string continues on the next line, with no newline addedNo
Comma after the last itemTrailing comma, one per object or arrayNo

The full rules are in the syntax reference and the data types page.

Editor icon

How to Open It on Windows, macOS and Linux

You need a text editor, not a special viewer. Prefer an editor that writes plain UTF-8 and does not replace straight quotes with curly ones. Word processors are the wrong tool because they add formatting or save another format.

Windows

Right-click the file, choose Open with, and pick Notepad, Notepad++, Visual Studio Code or another editor. To make the choice permanent, open Settings > Apps > Default apps and enter .json5 in the file type search box, as described by Microsoft Support. A new extension may have no association at all: on the Windows 11 machine used to test this page, assoc .json5 reported that none was found. From a terminal:

notepad server.json5 Get-Content server.json5

If you create or rewrite the file in Windows PowerShell 5.1, watch the encoding. Its > operator and Out-File write UTF-16LE by default, and a tool that reads the result as UTF-8 fails on the very first character. Pass -Encoding utf8, or use PowerShell 7.

macOS

In Finder, Control-click the file and choose Open With, then pick an editor. To change the default for all such files, choose Get Info, select an app under "Open with", and click Change All. Apple documents both steps. If you use TextEdit, work in plain text mode and check that quotes you type stay straight.

Linux

Any editor works: nano, Vim, Emacs, Kate, GNOME Text Editor or a graphical IDE. To set a default handler, ask the desktop what type it assigns, then point that type at an editor with xdg-mime:

xdg-mime query filetype server.json5 xdg-mime default org.kde.kate.desktop application/json5

Replace the desktop file name with your editor's. The xdg-mime manual notes that the application's desktop file must list the media type it is asked to handle. The current upstream shared-mime-info database already defines application/json5 for *.json5, but an older distribution release may not. If the query returns a generic type such as plain text, you can add a user-level type definition in the freedesktop shared MIME-info format:

<?xml version="1.0" encoding="UTF-8"?> <mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info"> <mime-type type="application/json5"> <comment>JSON5 document</comment> <glob pattern="*.json5"/> </mime-type> </mime-info>
xdg-mime install --mode user example-json5.xml
Tools icon

Editor Support

Opening the file is easy. Getting correct colors and error markers depends on whether the editor knows JSON5, as opposed to JSON or JSON with Comments (JSONC).

Editor.json5 out of the boxWhat to doGuide
Visual Studio CodeNo: the built-in JSON extension does not claim .json5Install Better JSON5 (highlighting, validation, formatting, schemas) or JSON5 syntax (highlighting)VS Code
WebStorm and JetBrains IDEsYes: WebStorm treats the extension as JSON5Optionally map other file name patterns to the JSON5 file typeJetBrains
VimYes: ships filetype detection and a syntax fileAdd plugins or a language server for schema checksVim and Neovim
EmacsNeeds a modeUse json5-ts-mode (needs a Tree-sitter grammar, and its README says multi-line strings are not supported), or js-mode as a stand-inEmacs
Sublime TextNo: the default JSON syntax does not list the extensionAssign a syntax to the extension and add a formatterSublime Text
Notepad++Yes: its language list maps json5 and jsonc to a JSON5 languageNothing extra for highlightingValidate separately
Kate and other KDE editorsYes: KSyntaxHighlighting has a JSON5 definitionNothing extra for highlightingValidate separately

In VS Code without any extension, you can borrow the JSONC highlighter. Expect it to complain about syntax that only JSON5 allows, such as unquoted keys and single quotes:

{ "files.associations": { "*.json5": "jsonc" } }

The Atom successor Pulsar is covered in the Atom guide. Command line options are on the CLI page.

Globe icon

Extension and MIME Type Facts

The conventional extension is .json5 and the conventional media type is application/json5. Neither is the product of a formal registration. The IANA list of application media types, checked on November 29, 2026, has no JSON5 entry, while it does list application/json, application/yaml and application/toml.

The convention comes from the project's issue tracker. Asked in 2013 which type the project would use, its creator answered that either application/vnd.json5 or application/json5 was fine (issue 40). Later answers from contributors settled on application/json5 (issue 80, issue 123).

SoftwareType it assigns to a .json5 file (default setup)
mime-db 1.54.0, used by the npm mime-types package, which Express 5 relies on for static filesapplication/json5, listed as a custom (non-IANA) type
freedesktop.org shared-mime-info, the type database of many Linux desktops (current development source)application/json5, described as "JSON5 document"
nginx mime.typesNo entry
Apache HTTP Server mime.typesNo entry
Python 3.14.4 mimetypes, tested on WindowsNo guess; http.server sends application/octet-stream

For the wider status question, see standards status.

Compare icon

.json5 or .json?

The extension is a promise to other tools. A .json name tells editors, linters, servers and scripts that a strict JSON parser will succeed. A .json5 name tells them to use a JSON5 parser.

  • Renaming JSON to JSON5 is syntactically safe, because the text stays valid. The program that loads the file still has to look for the new name.
  • Renaming JSON5 to JSON is not safe. The first comment or unquoted key makes a strict parser fail. Convert the content instead.
  • Some programs read JSON5 from a .json name. Babel parses babel.config.json and .babelrc.json as JSON5, and OpenClaw reads a JSON5 config from openclaw.json. That is their private rule; other tools may reject the same file.
  • Some names have a fixed format. npm requires package.json to be actual JSON. pnpm separately accepts a file named package.json5.

When you control the loader and the file uses JSON5 syntax, name it .json5. It avoids false errors in editors and tells the next reader what they are looking at. The comparison page weighs JSON5 against JSON, JSONC, YAML and TOML.

Plugin icon

Common Programs That Produce or Read .json5 Files

Each row below rests on the project's own documentation or source. Finding the file name here is the quickest way to learn what a stray file belongs to.

File name you may seeProgramRole
package.json5pnpmAlternative project manifest
renovate.json5, .renovaterc.json5RenovateDependency update bot settings
tauri.conf.json5TauriApp configuration, enabled by the config-json5 Cargo feature (file name from the parser source)
.json5 passed to --configelectron-builderPackaging configuration
app.json5OpenHarmony appsApplication-level configuration
module.json5OpenHarmony appsModule-level configuration
oh-package.json5OpenHarmony appsModule package description and dependencies
config/<name>.json5 in a Minecraft folderMods using Cloth ConfigMod settings written by the Jankson serializer
<name>.cml (not a .json5 name, but JSON5 inside)FuchsiaComponent manifest source
runtime_enabled_features.json5ChromiumBuild input listing runtime features
Locale files ending in .json5i18next-fs-backendTranslation resources

Jankson also accepts some Hjson features, so a mod config that loads in the game may still fail in a strict JSON5 parser. The longer, graded list is on who uses JSON5.

Convert icon

Convert .json5 to JSON

In the browser

The online converter runs in your browser, so the text is not uploaded. Choose the JSON5 to JSON direction, paste the file, pick an indent and copy the result.

On the command line

The reference package installs a command line tool. It reads a file or standard input and writes JSON:

npx json5 -s 2 server.json5 # print to the terminal npx json5 -s 2 -o server.json server.json5 # write a file npx json5 server.json5 # no -s: compact, one line

Output for the sample, using version 2.2.3:

{ "name": "inventory-api", "port": 8080, "fileMode": 420, "timeoutSeconds": 2.5, "retryBackoff": 0.25, "maxPayload": 1048576, "rateLimit": null, "banner": "Inventory service ready", "hosts": [ "api.example.com", "backup.example.com" ] }

What you lose

In the JSON5 fileIn the JSON outputWhy it matters
CommentsGoneExplanations cannot be recovered from the JSON
Infinity, -Infinity, NaNnullSilent change of meaning: "no limit" becomes "no value"
-00The sign of zero is dropped
0x1A4420Same value, less readable
90071992547409939007199254740992JavaScript numbers lose integer precision here, during parsing
Repeated key, such as {a:1,a:2}{"a":2}The reference library keeps the last one
Quote style, line continuations, trailing commasNormalizedCosmetic, but diffs get noisy

The Python command line tool behaves differently. In version 0.17.3 of the Python json5 package, python -m json5 --as-json printed "rateLimit": Infinity for the sample. A strict JSON parser rejects that output, so replace non-finite numbers before converting.

Keep the original file as the source and treat the JSON as a build product. If you only want tidy formatting, do not convert at all. Prettier 3.10.1 reformatted the sample with its json5 parser and kept all three comments, the unquoted keys and the special numbers, while changing the quotes to double quotes and 0x1A4 to 0x1a4:

npx prettier --parser json5 --write server.json5

More options, including the reverse direction, are in conversion tools and formatting tools.

Test icon

Validate the File

For a one-off check, paste it into the online validator, which reports the line and column of the first error. In a terminal, the -v flag parses without printing JSON. It is silent with exit code 0 on success and prints the error with exit code 1 on failure:

npx json5 -v server.json5 npx json5 -v bad.json5 # JSON5: invalid character 'p' at 3:3

Here bad.json5 omits the comma after its first property, so the parser stops at the p of the second key on line 3, column 3. To check many files in continuous integration, a short script gives clearer output:

// check-json5.js (npm install json5) const fs = require('node:fs'); const parser = require('json5'); let bad = 0; for (const file of process.argv.slice(2)) { try { parser.parse(fs.readFileSync(file, 'utf8')); console.log(`ok ${file}`); } catch (err) { bad++; console.error(`FAIL ${file}:${err.lineNumber}:${err.columnNumber} ${err.message}`); } } process.exitCode = bad ? 1 : 0;
node check-json5.js server.json5 bad.json5 # ok server.json5 # FAIL bad.json5:3:3 JSON5: invalid character 'p' at 3:3

For lint rules such as duplicate keys, the official ESLint JSON plugin has a json/json5 language. Syntax checks do not prove that the keys and types are what a program expects; that needs a schema. See also validation tools.

Server icon

Serve a .json5 File over HTTP

Send Content-Type: application/json5. Labeling the file application/json invites clients to run a strict JSON parser on it. Servers that have no mapping need one line of configuration.

nginx

Add the mapping to the types block in your mime.types file. If the file should be compressed, also name the type in gzip_types, whose default covers only text/html.

# mime.types, inside types { ... } application/json5 json5; # nginx.conf gzip on; gzip_types application/json application/json5;

Apache HTTP Server

Use AddType in the server configuration or an .htaccess file:

AddType application/json5 .json5

IIS

IIS serves static files only for extensions it has a MIME mapping for; an unmapped one produces a 404.3 error. Add a mimeMap entry:

<configuration> <system.webServer> <staticContent> <mimeMap fileExtension=".json5" mimeType="application/json5" /> </staticContent> </system.webServer> </configuration>

Cloudflare Pages and Node.js

On Cloudflare Pages, set the header in a _headers file. Express 5 static serving already picks application/json5 through mime-types.

# _headers /server.json5 Content-Type: application/json5

Reading it in the browser

response.json() uses the strict JSON rules, whatever the header says. Read text and parse it with a JSON5 library. The bare import below assumes a bundler or an import map that resolves the package name:

import parser from 'json5'; const response = await fetch('/server.json5'); if (!response.ok) throw new Error(`HTTP ${response.status}`); const settings = parser.parse(await response.text());

Remember that a file under your web root is public. Do not publish configuration that contains credentials. For data exchanged between programs, strict JSON remains the better choice.

Bug icon

Why a Program Rejects Your File

First find out what parser the program uses. If the file passes npx json5 -v but the program still fails, the program is probably using strict JSON or JSONC, or it adds its own rules about keys and values. Renaming the file will not change its parser.

If the validator also fails, match the message. All messages below were produced with version 2.2.3; positions are line:column.

InputMessageFix
Empty file, or only a commentinvalid end of inputA document needs one value; use {} for no settings
{content-type: 1}invalid character '-'Quote keys that contain hyphens or spaces, or start with a digit
Backtick stringinvalid character '`'Use single or double quotes
# commentinvalid character '#'Use // or /* */
Two objects one after anotherinvalid character '{'Wrap them in one array, or split the file
010invalid character '1'Remove the leading zero
1_000invalid character '_'Write 1000
undefinedinvalid character 'u'Use null or omit the key
Unquoted date 2026-01-01invalid character '-'Write the date as a string
Raw line break inside a stringinvalid character '\n'Use \n, or end the line with a backslash
Curly quotes pasted from a documentinvalid character, showing the curly quoteReplace them with straight quotes
Doubled comma, such as [1,,]invalid character ','Remove the extra comma; only one trailing comma is allowed
UTF-16 file with a byte order mark, read as UTF-8invalid character at 1:1Save again as UTF-8

A UTF-8 byte order mark did not trouble the reference parser in the same test, although other parsers may treat it differently. Deeper help is in parse errors, encoding problems, common mistakes and the error reference.

Question icon

Common questions

Is a .json5 file safe to open?

Opening it in a text editor only displays text. The risk comes from programs that act on its settings, so treat a configuration file from a stranger as you would any other: read it before you point a tool at it.

Can I just change the extension to .json?

Only if the content already happens to be strict JSON. Otherwise the program that reads the new name will fail. Convert it with the online converter or the command line tool, and keep the original.

Can a spreadsheet or browser open it?

A browser may show or download it depending on the media type the server sends. It is a nested text structure, so a spreadsheet will not turn it into a table without a conversion step.

Is it the fifth version of JSON?

No. It is a separate, community-defined superset, and standard JSON parsers do not accept its additions. The history page explains where it came from.

Which programming languages can read it?

Libraries exist for many languages. Start with the implementations directory or the guides for JavaScript and Python.

Sources

(49)
  1. The JSON5 Data Interchange Format, 1.0.0
  2. json5/json5 README
  3. json5 command line source (lib/cli.js)
  4. IANA media types: application registry (CSV)
  5. json5 issue 40: mime type
  6. json5 issue 80: Clarify Mime type
  7. json5 issue 123: MIME type
  8. jshttp/mime-db custom types
  9. freedesktop.org shared-mime-info type database
  10. nginx default mime.types
  11. Apache httpd mime.types
  12. GitHub Linguist languages.yml
  13. Microsoft Support: Change default apps in Windows
  14. Microsoft Learn: about_Character_Encoding (Windows PowerShell 5.1)
  15. Apple: Choose an app to open a file on Mac
  16. freedesktop.org: xdg-mime manual
  17. VS Code built-in JSON extension manifest
  18. Visual Studio Marketplace: Better JSON5
  19. Visual Studio Marketplace: JSON5 syntax
  20. WebStorm help: JSON
  21. Vim runtime: filetype detection
  22. Vim runtime: json5 syntax file
  23. MELPA recipe: json5-ts-mode
  24. Sublime Text default JSON syntax
  25. Notepad++ langs.model.xml
  26. KDE KSyntaxHighlighting: json5.xml
  27. npm docs: package.json
  28. Babel docs: configuration files
  29. OpenClaw docs: configuration
  30. pnpm docs: package.json
  31. Renovate docs: configuration options
  32. Tauri docs: configuration files
  33. Tauri source: config/parse.rs
  34. electron-builder docs: configuration
  35. OpenHarmony docs: app.json5
  36. OpenHarmony docs: module.json5
  37. OpenHarmony docs: HAR package
  38. Cloth Config: JanksonConfigSerializer source
  39. falkreon/Jankson
  40. Fuchsia docs: component manifests
  41. Chromium: runtime_enabled_features.json5
  42. i18next-fs-backend README
  43. PyPI: json5
  44. eslint/json README
  45. nginx: ngx_http_gzip_module
  46. Apache: mod_mime
  47. Microsoft (archived, IIS 6): requests for static files return 404
  48. Microsoft Learn: IIS mimeMap
  49. Cloudflare Pages: Headers

Last reviewed: November 29, 2026.