# json-schema-compare

> Compare json schemas smarter.

Latest version **0.2.2** (published 2017-10-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install json-schema-compare
pnpm add json-schema-compare
yarn add json-schema-compare
bun add json-schema-compare
```

## Health

**Score 23/100 (F)** — status: abandoned.

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.2 |
| Published | 2017-10-22 |
| First published | 2017-10-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/json-schema-compare) |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 18 |
| Author | Martin Hansen |
| Maintainers | mokkabonna |
| Keywords | json, schema, jsonschema, json-schema, comparison |

## Links

- npm: https://www.npmjs.com/package/json-schema-compare
- Repository: https://github.com/mokkabonna/json-schema-compare
- Homepage: https://github.com/mokkabonna/json-schema-compare#readme
- Issues: https://github.com/mokkabonna/json-schema-compare/issues
- npm.io page: https://npm.io/package/json-schema-compare

## Dependencies (1)

- [lodash](https://npm.io/package/lodash.md) ^4.17.4

## 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

- 0.2.2 (latest) — 2017-10-22
- 0.2.1 — 2017-10-22
- 0.2.0 — 2017-10-21

## README

# json-schema-compare [![Build Status](https://travis-ci.org/mokkabonna/json-schema-compare.svg?branch=master)](https://travis-ci.org/mokkabonna/json-schema-compare) [![Coverage Status](https://coveralls.io/repos/github/mokkabonna/json-schema-compare/badge.svg?branch=master)](https://coveralls.io/github/mokkabonna/json-schema-compare?branch=master)


> Compare json schemas correctly

```bash
npm install json-schema-compare --save
```

```js
var compare = require('json-schema-compare')

var isEqual = compare({
  title: 'title 1',
  type: ['object'],
  uniqueItems: false,
  dependencies: {
    name: ['age', 'lastName']
  },
  required: ['name', 'age', 'name']
}, {
  title: 'title 2',
  type: 'object',
  required: ['age', 'name'],
  dependencies: {
    name: ['lastName', 'age']
  },
  properties: {
    name: {
      minLength: 0
    }
  }
}, {
  ignore: ['title']
})

console.log(isEqual) // => true
```

Compare json schemas correctly.

- Ignores sort for arrays where sort does not matter, like required, enum, type, anyOf, oneOf, anyOf, dependencies (if array)
- Compares correctly type when array or string
- Ignores duplicate values before comparing
- For schemas and sub schemas `undefined`, `true` and `{}` are equal
- For minLength, minItems and minProperties `undefined` and `0` are equal
- For uniqueItems, `undefined` and `false` are equal


## Options

**ignore** array - default: `[]`

Ignores certain keywords, useful to exclude meta keywords like title, description etc or custom keywords. If all you want to know if they are the same in terms of validation keywords.


## Contributing

Create tests for new functionality and follow the eslint rules.

## License

MIT © [Martin Hansen](http://martinhansen.com)

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