# @codemirror/lang-json

> JSON language support for the CodeMirror code editor

Latest version **6.0.2** (published 2025-06-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install @codemirror/lang-json
pnpm add @codemirror/lang-json
yarn add @codemirror/lang-json
bun add @codemirror/lang-json
```

## Health

**Score 50/100 (C)** — status: stable.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: stale.

## Facts

| | |
|---|---|
| Version | 6.0.2 |
| Published | 2025-06-19 |
| First published | 2020-12-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 10.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 33 |
| Author | Marijn Haverbeke |
| Maintainers | adrianheine, marijn |
| Keywords | editor, code |

## Links

- npm: https://www.npmjs.com/package/@codemirror/lang-json
- Repository: https://github.com/codemirror/lang-json
- Homepage: https://github.com/codemirror/lang-json#readme
- Issues: https://github.com/codemirror/lang-json/issues
- npm.io page: https://npm.io/package/@codemirror/lang-json

## Dependencies (2)

- [@lezer/json](https://npm.io/package/@lezer/json.md) ^1.0.0
- [@codemirror/language](https://npm.io/package/@codemirror/language.md) ^6.0.0

## Alternatives

- [flatbuffers](https://npm.io/package/flatbuffers.md) — 6.0M weekly downloads
- [jwt-simple](https://npm.io/package/jwt-simple.md) — 259.5K weekly downloads
- [@exodus/patch-broken-hermes-typed-arrays](https://npm.io/package/@exodus/patch-broken-hermes-typed-arrays.md) — 28.5K weekly downloads
- [@native-to-anchor/buffer-layout](https://npm.io/package/@native-to-anchor/buffer-layout.md) — 12.2K weekly downloads
- [binary-parser-encoder](https://npm.io/package/binary-parser-encoder.md) — 5.3K weekly downloads

## Recent versions

- 6.0.2 (latest) — 2025-06-19
- 6.0.1 — 2022-10-24
- 6.0.0 — 2022-06-08
- 0.20.0 — 2022-04-20
- 0.19.2 — 2022-02-15
- 0.19.1 — 2021-08-11
- 0.19.0 — 2021-08-11
- 0.18.0 — 2021-03-03
- 0.17.1 — 2021-01-06
- 0.17.0 — 2020-12-29

## README

<!-- NOTE: README.md is generated from src/README.md -->

# @codemirror/lang-json [![NPM version](https://img.shields.io/npm/v/@codemirror/lang-json.svg)](https://www.npmjs.org/package/@codemirror/lang-json)

[ [**WEBSITE**](https://codemirror.net/) | [**ISSUES**](https://github.com/codemirror/dev/issues) | [**FORUM**](https://discuss.codemirror.net/c/next/) | [**CHANGELOG**](https://github.com/codemirror/lang-json/blob/main/CHANGELOG.md) ]

This package implements JSON language support for the
[CodeMirror](https://codemirror.net/) code editor.

The [project page](https://codemirror.net/) has more information, a
number of [examples](https://codemirror.net/examples/) and the
[documentation](https://codemirror.net/docs/).

This code is released under an
[MIT license](https://github.com/codemirror/lang-json/tree/main/LICENSE).

We aim to be an inclusive, welcoming community. To make that explicit,
we have a [code of
conduct](http://contributor-covenant.org/version/1/1/0/) that applies
to communication around the project.

## Usage

```javascript
import {EditorView, basicSetup} from "codemirror"
import {json} from "@codemirror/lang-json"

const view = new EditorView({
  parent: document.body,
  doc: `{"version": "9.99.99", "data": [1, 2, 3]}`,
  extensions: [basicSetup, json()]
})
```

## API Reference

<dl>
<dt id="user-content-json">
  <code><strong><a href="#user-content-json">json</a></strong>() → <a href="https://codemirror.net/docs/ref#language.LanguageSupport">LanguageSupport</a></code></dt>

<dd><p>JSON language support.</p>
</dd>
<dt id="user-content-jsonlanguage">
  <code><strong><a href="#user-content-jsonlanguage">jsonLanguage</a></strong>: <a href="https://codemirror.net/docs/ref#language.LRLanguage">LRLanguage</a></code></dt>

<dd><p>A language provider that provides JSON parsing.</p>
</dd>
<dt id="user-content-jsonparselinter">
  <code><strong><a href="#user-content-jsonparselinter">jsonParseLinter</a></strong>() → fn(<a id="user-content-jsonparselinter^returns^view" href="#user-content-jsonparselinter^returns^view">view</a>: <a href="https://codemirror.net/docs/ref#view.EditorView">EditorView</a>) → <a href="https://codemirror.net/docs/ref#lint.Diagnostic">Diagnostic</a>[]</code></dt>

<dd><p>Calls
<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse"><code>JSON.parse</code></a>
on the document and, if that throws an error, reports it as a
single diagnostic.</p>
</dd>
</dl>

---
_Source: https://npm.io/package/@codemirror/lang-json · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
