# json2gbnf

> A library for turning JSON schemas into GBNF grammars

Latest version **0.1.4** (published 2024-11-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install json2gbnf
pnpm add json2gbnf
yarn add json2gbnf
bun add json2gbnf
```

## Health

**Score 45/100 (D)** — status: stable.

Positive: esm support; no vulnerabilities; has provenance.

Warnings: low downloads; no types; pre 1.0.

Negative: stale.

## Facts

| | |
|---|---|
| Version | 0.1.4 |
| Published | 2024-11-24 |
| First published | 2024-10-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 245.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 4 |
| Author | Ambient Labs |
| Maintainers | ambient-labs |
| Keywords | json, gbnf, grammar |

## Links

- npm: https://www.npmjs.com/package/json2gbnf
- Repository: https://github.com/ambient-labs/GBNF
- Homepage: https://github.com/ambient-labs/GBNF#readme
- Issues: https://github.com/ambient-labs/GBNF/issues
- npm.io page: https://npm.io/package/json2gbnf

## 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.1.4 (latest) — 2024-11-24
- 0.1.3 — 2024-10-08
- 0.1.2 — 2024-10-07

## README

# JSON2GBNF

<a href="https://www.npmjs.com/package/json2gbnf"><img alt="Latest json2gbnf NPM Version" src="https://badge.fury.io/js/json2gbnf.svg" /></a>
<a href="https://github.com/ambient-labs/json2gbnf/blob/master/packages/json2gbnf/LICENSE"><img alt="License for json2gbnf" src="https://img.shields.io/npm/l/json2gbnf" /></a>
<a href="https://www.npmjs.com/package/json2gbnf"><img alt="Downloads per week on NPM for json2gbnf" src="https://img.shields.io/npm/dw/json2gbnf" /></a>
<a href="https://github.com/ambient-labs/GBNF/actions/workflows/tests.yml"><img src="https://github.com/ambient-labs/GBNF/actions/workflows/tests.yml/badge.svg" alt="Status of tests for json2gbnf repository" /></a>
<a href="https://codecov.io/gh/ambient-labs/GBNF"><img alt="Code Coverage for json2gbnf" src="https://img.shields.io/codecov/c/github/ambient-labs/GBNF" /></a>
<a href="https://deepsource.io/gh/ambient-labs/GBNF/?ref=repository-badge"><img alt="DeepSource issues for json2gbnf" src="https://deepsource.io/gh/ambient-labs/GBNF.svg/?label=active+issues&show_trend=true" /></a>

A library for parsing JSON schema definitions into  `.gbnf` grammar files in Javascript.

## Install

```bash
npm install json2gbnf
```

## Usage

```
import JSON2GBNF from 'json2gbnf';

const grammar = JSON2GBNF({
  type: 'object',
  properties: {
    number: { type: 'number' },
    street_name: { type: 'string' },
    street_type: { enum: ['Street', 'Avenue', 'Boulevard'] },

  },
});

console.log(grammar); // GBNF grammar
```

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