# @apidevtools/json-schema-ref-parser

> Parse, Resolve, and Dereference JSON Schema $ref pointers

Latest version **16.0.2** (published 2026-09-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install @apidevtools/json-schema-ref-parser
pnpm add @apidevtools/json-schema-ref-parser
yarn add @apidevtools/json-schema-ref-parser
bun add @apidevtools/json-schema-ref-parser
```

## Health

**Score 75/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; has provenance; recently updated; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 16.0.2 |
| Published | 2026-09-06 |
| First published | 2020-03-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=22.19.0 |
| Dependencies | 2 |
| Unpacked size | 466.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 1116 |
| Author | JonLuca DeCaro |
| Maintainers | jonluca, jamesmessinger, philsturgeon |
| Keywords | json, schema, jsonschema, json-schema, json-pointer, $ref, dereference, resolve |

## Links

- npm: https://www.npmjs.com/package/@apidevtools/json-schema-ref-parser
- Repository: https://github.com/APIDevTools/json-schema-ref-parser
- Homepage: https://apidevtools.com/json-schema-ref-parser/
- Issues: https://github.com/APIDevTools/json-schema-ref-parser/issues
- npm.io page: https://npm.io/package/@apidevtools/json-schema-ref-parser

## Dependencies (2)

- [undici](https://npm.io/package/undici.md) ^8.10.2
- [js-yaml](https://npm.io/package/js-yaml.md) ^5.4.1

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 16.0.2 (latest) — 2026-09-06
- 9.1.2 (release-v9.1.x) — 2023-01-25
- 16.0.1 — 2026-08-26
- 16.0.0 — 2026-08-14
- 15.5.2 — 2026-08-14
- 15.5.1 — 2026-07-30
- 15.5.0 — 2026-07-09
- 15.4.0 — 2026-06-19
- 15.3.6 — 2026-06-11
- 15.3.5 — 2026-03-30
- 15.3.4 — 2026-03-27
- 15.3.3 — 2026-03-26
- 15.3.2 — 2026-03-23
- 15.3.1 — 2026-02-28
- 15.3.0 — 2026-02-28
- … 75 more at https://npm.io/package/@apidevtools/json-schema-ref-parser/versions

## README

# JSON Schema $Ref Parser

#### Parse, Resolve, and Dereference JSON Schema $ref pointers

[![Build Status](https://github.com/APIDevTools/json-schema-ref-parser/workflows/CI-CD/badge.svg?branch=master)](https://github.com/APIDevTools/json-schema-ref-parser/actions)
[![Coverage Status](https://coveralls.io/repos/github/APIDevTools/json-schema-ref-parser/badge.svg?branch=master)](https://coveralls.io/github/APIDevTools/json-schema-ref-parser)

[![npm](https://img.shields.io/npm/v/@apidevtools/json-schema-ref-parser.svg)](https://www.npmjs.com/package/@apidevtools/json-schema-ref-parser)
[![License](https://img.shields.io/npm/l/@apidevtools/json-schema-ref-parser.svg)](LICENSE)
[![Buy us a tree](https://img.shields.io/badge/Treeware-%F0%9F%8C%B3-lightgreen)](https://plant.treeware.earth/APIDevTools/json-schema-ref-parser)

## Installation

Install using [npm](https://docs.npmjs.com/about-npm/):

```bash
npm install @apidevtools/json-schema-ref-parser
pnpm add @apidevtools/json-schema-ref-parser
bun add @apidevtools/json-schema-ref-parser
```

## The Problem:

You've got a JSON Schema with `$ref` pointers to other files and/or URLs. Maybe you know all the referenced files ahead
of time. Maybe you don't. Maybe some are local files, and others are remote URLs. Maybe they are a mix of JSON and YAML
format. Maybe some of the files contain cross-references to each other.

```json
{
  "definitions": {
    "person": {
      "$ref": "schemas/people/Bruce-Wayne.json"
    },
    "place": {
      "$ref": "schemas/places.yaml#/definitions/Gotham-City"
    },
    "thing": {
      "$ref": "http://wayne-enterprises.com/things/batmobile"
    },
    "color": {
      "$ref": "#/definitions/thing/properties/colors/black-as-the-night"
    }
  }
}
```

## The Solution:

JSON Schema $Ref Parser is a full [JSON Reference](https://tools.ietf.org/html/draft-pbryan-zyp-json-ref-03)
and [JSON Pointer](https://tools.ietf.org/html/rfc6901) implementation that crawls even the most
complex [JSON Schemas](http://json-schema.org/latest/json-schema-core.html) and gives you simple, straightforward
JavaScript objects.

- Use **JSON** or **YAML** schemas &mdash; or even a mix of both!
- Supports `$ref` pointers to external files and URLs, as well
  as [custom sources](https://apidevtools.com/json-schema-ref-parser/docs/plugins/resolvers.html) such as databases
- Can [bundle](https://apidevtools.com/json-schema-ref-parser/docs/ref-parser.html#bundlepath-options-callback) multiple
  files into a single schema that only has _internal_ `$ref` pointers
- Can [dereference](https://apidevtools.com/json-schema-ref-parser/docs/ref-parser.html#dereferencepath-options-callback)
  your schema, producing a plain-old JavaScript object that's easy to work with
- Supports [circular references](https://apidevtools.com/json-schema-ref-parser/docs/#circular-refs), nested references,
  back-references, and cross-references between files
- Maintains object reference equality &mdash; `$ref` pointers to the same value always resolve to the same object
  instance
- Compatible with Node LTS and beyond, and all major web browsers on Windows, Mac, and Linux

## Example

```javascript
import $RefParser from "@apidevtools/json-schema-ref-parser";

try {
  await $RefParser.dereference(mySchema);
  // note - by default, mySchema is modified in place, and the returned value is a reference to the same object
  console.log(mySchema.definitions.person.properties.firstName);

  // if you want to avoid modifying the original schema, you can disable the `mutateInputSchema` option
  let clonedSchema = await $RefParser.dereference(mySchema, { mutateInputSchema: false });
  console.log(clonedSchema.definitions.person.properties.firstName);
} catch (err) {
  console.error(err);
}
```

For more detailed examples, please see the [API Documentation](https://apidevtools.com/json-schema-ref-parser/docs/)

## Polyfills

If you are using Node.js < 18, you'll need a polyfill for `fetch`,
like [node-fetch](https://github.com/node-fetch/node-fetch):

```javascript
import fetch from "node-fetch";

globalThis.fetch = fetch;
```

## Browser support

JSON Schema $Ref Parser supports recent versions of every major web browser. Older browsers may
require [Babel](https://babeljs.io/) and/or [polyfills](https://babeljs.io/docs/en/next/babel-polyfill).

To use JSON Schema $Ref Parser in a browser, you'll need to use a bundling tool such
as [Webpack](https://webpack.js.org/), [Rollup](https://rollupjs.org/), [Parcel](https://parceljs.org/),
or [Browserify](http://browserify.org/). Some bundlers may require a bit of configuration, such as
setting `browser: true` in [rollup-plugin-resolve](https://github.com/rollup/rollup-plugin-node-resolve).

#### Webpack 5

Webpack 5 has dropped the default export of node core modules in favour of polyfills, you'll need to set them up
yourself ( after npm-installing them )
Edit your `webpack.config.js` :

```js
config.resolve.fallback = {
  path: require.resolve("path-browserify"),
  fs: require.resolve("browserify-fs"),
};

config.plugins.push(
  new webpack.ProvidePlugin({
    Buffer: ["buffer", "Buffer"],
  }),
);
```

## API Documentation

Full API documentation is available [right here](https://apidevtools.com/json-schema-ref-parser/docs/)

## Contributing

I welcome any contributions, enhancements, and
bug-fixes. [Open an issue](https://github.com/APIDevTools/json-schema-ref-parser/issues) on GitHub
and [submit a pull request](https://github.com/APIDevTools/json-schema-ref-parser/pulls).

#### Building/Testing

To build/test the project locally on your computer:

1. **Clone this repo**<br>
   `git clone https://github.com/APIDevTools/json-schema-ref-parser.git`

2. **Install dependencies**<br>
   `pnpm install`

3. **Run the tests**<br>
   `pnpm test`

## License

JSON Schema $Ref Parser is 100% free and open-source, under the [MIT license](LICENSE). Use it however you want.

## Thanks

Thanks to these awesome contributors for their major support of this open-source project.

- [JonLuca De Caro](https://jonlu.ca)
- [Phil Sturgeon](https://philsturgeon.com)
- [Stoplight](https://stoplight.io/?utm_source=github&utm_medium=readme&utm_campaign=json_schema_ref_parser)

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