The `har-schema` package provides the official JSON Schema definitions for the HTTP Archive (HAR) format, enabling robust validation of HAR files. It encompasses schemas for all HAR entities, including `log`, `pages`, `entries`, `requests`, `responses`, and more. The current stable version, 2.0.0 (released in 2017), migrated its schemas to conform with JSON-Schema Draft-06, a significant breaking change from prior versions. This package is foundational for tools that process or validate HAR data, acting as a data source for schema definitions rather than an executable library. Its release cadence is effectively dormant, with no new feature development since 2017, reflecting the stability of the HAR 1.2 specification it implements. It differentiates itself by being the direct, standard representation of the HAR spec in JSON Schema, compatible with any generic JSON Schema validation library.
npm install har-schemaVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to import the HAR schema and use it with the AJV validation library to validate both a minimal valid HAR object and an intentionally invalid one. It also shows how to access and validate individual HAR component schemas.
Ensure your JSON Schema validator (e.g., Ajv) is configured to use Draft-06 or a compatible newer draft, or upgrade your validator library if it's too old.
Be aware of the project's inactive status. If your project requires validation against newer HAR specifications or the latest JSON Schema drafts, you may need to find an alternative or fork this repository.
Install a compatible JSON Schema validation library (e.g., `npm install ajv`) and use it in conjunction with `har-schema` to perform validation.
Run `npm install har-schema` or `yarn add har-schema` in your project directory.
Ensure your validator is set up to correctly parse Draft-06 schemas. For AJV, initialize with `new Ajv()` which defaults to Draft-07 (compatible), or explicitly `new Ajv({ allErrors: true, messages: true, schemaId: 'id' })` for Draft-06 specific handling if needed.Ensure your `tsconfig.json` has `"esModuleInterop": true` and `"allowSyntheticDefaultImports": true`. If using `require`, ensure you're accessing `require('har-schema').har`.No dependency data recorded yet.