# jsonschema-bigquery

> Convert JSON schema to Google BigQuery schema

Latest version **7.0.2** (published 2025-10-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install jsonschema-bigquery
pnpm add jsonschema-bigquery
yarn add jsonschema-bigquery
bun add jsonschema-bigquery
```

Provides the command `jsbq`.

## Health

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

Positive: no vulnerabilities; high maintenance score.

Warnings: low downloads; no types; no esm support.

Negative: stale.

## Facts

| | |
|---|---|
| Version | 7.0.2 |
| Published | 2025-10-11 |
| First published | 2018-07-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=12 |
| Dependencies | 4 |
| Unpacked size | 54.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 26 |
| Author | thedumbterminal |
| Maintainers | thedumbterminal, paparomeo |
| Keywords | json, schema, google, bigquery, convert |

## Links

- npm: https://www.npmjs.com/package/jsonschema-bigquery
- Repository: https://github.com/thedumbterminal/jsonschema-bigquery
- Homepage: https://github.com/thedumbterminal/jsonschema-bigquery#readme
- Issues: https://github.com/thedumbterminal/jsonschema-bigquery/issues
- npm.io page: https://npm.io/package/jsonschema-bigquery

## Dependencies (4)

- [yargs](https://npm.io/package/yargs.md) ^18.0.0
- [lodash](https://npm.io/package/lodash.md) ^4.17.20
- [log4js](https://npm.io/package/log4js.md) ^6.3.0
- [@google-cloud/bigquery](https://npm.io/package/@google-cloud/bigquery.md) ^8.0.0

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

- 7.0.2 (latest) — 2025-10-11
- 7.0.1 — 2025-09-30
- 7.0.0 — 2023-04-03
- 6.1.0 — 2023-01-27
- 6.0.0 — 2023-01-24
- 5.1.0 — 2022-08-11
- 5.0.1 — 2022-07-04
- 5.0.0 — 2021-12-30
- 4.1.0 — 2021-09-27
- 4.0.1 — 2021-02-12
- 4.0.0 — 2020-12-24
- 3.4.0 — 2020-06-03
- 3.3.0 — 2020-05-23
- 3.2.1 — 2020-05-23
- 3.2.0 — 2020-02-28
- … 18 more at https://npm.io/package/jsonschema-bigquery/versions

## README

# jsonschema-bigquery

[![npm](https://img.shields.io/npm/v/jsonschema-bigquery.svg)](https://www.npmjs.com/package/jsonschema-bigquery)
[![Node.js CI](https://github.com/thedumbterminal/jsonschema-bigquery/actions/workflows/main.yml/badge.svg)](https://github.com/thedumbterminal/jsonschema-bigquery/actions/workflows/main.yml)

Convert JSON schema to Google BigQuery schema

This includes the ability to:

1. Create tables
1. Patch tables

Further enhancements are planned: delete tables (dev only), create dataset, set data ACLs

Note that some features involve bespoke interpretation of schema details suited to our environment.

## Install

    npm install jsonschema-bigquery

## Consume

    jsbq -p <gbq project> -d <gbq dataset> -j <json schema file> --preventAdditionalObjectProperties --continueOnError

For embedded usage the following will allow and support runtime schema conversion and table maintenance:

    const jsonSchemaBigquery = require('jsonschema-bigquery')
    const bigquerySchema = jsonSchemaBigquery.run(jsonSchemaObject, options)

Please ensure that the input JSON schema is dereferenced so that all external references have been resolved. [json-schema-ref-parser](https://www.npmjs.com/package/json-schema-ref-parser) can do this, prior to using this module.

### Options

```
{
  preventAdditionalObjectProperties: true,
  continueOnError: false
}
```

- `preventAdditionalObjectProperties` - boolean, check for additional object properties in schemas.
- `continueOnError` - boolean, continues conversion if problem JSON is encountered. Problems will be excluded from resulting schema.

### Usage with bq CLI tool

Google maintains a CLI tool called `bq` which allows the management of BigQuery tables:

https://cloud.google.com/bigquery/docs/reference/bq-cli-reference

To create a table from a JSON schema using other options that our `jsbq` does not support, use the following commands:

First, output the generated GBQ schema to a file:

```
npx jsbq -j test/integration/samples/complex/input.json > /tmp/schema.json
```

Then run the `bq` command to create a table:

```
bq mk --schema=/tmp/schema.json test_dataset.test_table
```

Please see the bq reference for table creation options:

https://cloud.google.com/bigquery/docs/reference/bq-cli-reference#bq_mk

## Test

    npm test

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