# Data Contract Generator and Validator

> Make a data contract from a CSV, Excel, JSON or Parquet file, then check new files against it. Saves ODCS YAML or a dbt schema.yml. Free, in your browser.

Page: https://datautility.in/data-contract-generator
This is the Markdown copy of the page. The tool itself runs in the browser: your files are processed on your own device and are not uploaded.

**Quick answer:** Write a data contract from a file, then check new files against it.

## How to use the Data Contract Generator and Validator

The Data Contract tool writes a data contract from a sample file and checks new files against it. A data contract is a short written promise about a dataset: which columns it has, their types, which values may be empty, which must be unique, which values are allowed and how many rows to expect. The tool profiles your CSV, Excel, JSON or Parquet file, suggests rules and lets you switch each one on or off. It saves the result as an Open Data Contract Standard (ODCS) YAML file, or as a dbt schema.yml with the same rules as dbt tests. In the Validate tab you drop a new file and a contract, and see which rules pass or fail, how many rows break each rule, and example rows. Everything runs in your browser.

1. Load a sample file
2. Tick the rules you want and download the contract
3. Validate a new file against it

## What it does

- Contract made from a sample file
- Saved as ODCS YAML or a dbt schema.yml
- Pass or fail per rule, with example rows
- Nothing is uploaded

## Tips

- The rules are suggestions from one file. Lists of allowed values, ranges and lengths start switched off because a single sample can mislead.
- Row numbers in the results count data rows from 1, not counting the header line.
- A column that is in the contract but not in the file fails the check, and its other rules are skipped. Extra columns fail too unless you untick that option.
- Rules this tool cannot run, such as SQL checks in a contract written elsewhere, are listed as warnings and are not checked.

## Example

Input:

```
orders.csv: order_id, status, unit_price
```

Output:

```
kind: DataContract
schema:
  - name: orders
    properties:
      - name: order_id
        logicalType: integer
        required: true
        unique: true
```

## Frequently asked questions

### What is a data contract?
A written promise about what a dataset must look like, stored as a YAML file: column names and types, which values may be empty, which must be unique, which values are allowed, and how many rows to expect.

### How are the rules made?
The tool profiles your sample file and suggests rules. Rules that one sample can get wrong, such as value lists and ranges, start switched off, and you can switch every rule on or off.

### Is my file uploaded?
No. The file is read and checked in your browser, and the contract is made there too.

### Which contract format does it use?
The Open Data Contract Standard (ODCS) version 3, published at bitol.io. Other tools that read ODCS can use the file. You can also save the same rules as a dbt schema.yml.

### Can I trust the rules it suggests?
Treat them as a first draft. They describe the one file you loaded, not every future file. Review them, and keep only the rules you would defend.

### Is my data uploaded?
No. Everything runs in your browser and nothing is stored.

## Related pages

- [ODCS Data Contract Generator](https://datautility.in/odcs-data-contract-generator): Generate an Open Data Contract Standard (ODCS) v3 YAML file from a CSV, Excel, JSON or Parquet file. Edit the rules, then download. Free, in your browser.
- [Validate a CSV Against a Schema](https://datautility.in/validate-csv-against-schema): Check a CSV or Excel file against a data contract: required values, types, unique columns, allowed values, ranges, patterns and missing or extra columns. Free, in your browser.

## Topic guides

- [Test Data Guides and Free Generators](https://datautility.in/guides/test-data)
- [File Format Guides and Free Tools](https://datautility.in/guides/file-formats)

## Guides

- [Data Contract Example in YAML: Write One and Validate a CSV Against It](https://datautility.in/blog/data-contract-example-yaml-validate-csv)
- [Data Contract Template (ODCS YAML): Copy It and Learn What Every Line Means](https://datautility.in/blog/data-contract-template-odcs-yaml)
- [Data Contract Rules Explained: Required, Unique, Allowed Values, Range and More](https://datautility.in/blog/data-contract-rules-explained-required-unique-allowed-range)
- [Validate a Vendor CSV Before Loading It Into Your Warehouse](https://datautility.in/blog/validate-vendor-csv-before-loading-warehouse)

Open the tool: https://datautility.in/data-contract-generator
