Getting started
fhir-resource-diff is a CLI and library for comparing and validating FHIR JSON resources — fast, local, no infrastructure dependencies.
Install
bash
# Global install (recommended for CLI use)
npm install -g fhir-resource-diff
# or
pnpm add -g fhir-resource-diff
# Project-local (for library use or CI)
pnpm add -D fhir-resource-diffFirst commands
Validate a resource
bash
fhir-resource-diff validate patient.json
# → validWith a specific FHIR version:
bash
fhir-resource-diff validate patient.json --fhir-version R4valid
ℹ For full FHIR schema validation, use the official HL7 FHIR Validator
→ https://confluence.hl7.org/display/FHIR/Using+the+FHIR+ValidatorThe note about the HL7 Validator is always shown when --fhir-version is specified — it's a footer about scope, not a finding about your resource.
Compare two resources
bash
fhir-resource-diff compare expected.json actual.jsonResourceType: Patient
Status: 3 difference(s) found
Changed:
birthDate: "1974-12-25" → "1974-12-26"
name[0].given[0]: "Peter" → "Pete"
Added:
telecom[2].systemLook up a resource type
bash
fhir-resource-diff info PatientPatient (base)
FHIR versions: R4, R4B, R5
Documentation:
R4: https://hl7.org/fhir/R4/patient.html
R4B: https://hl7.org/fhir/R4B/patient.html
R5: https://hl7.org/fhir/R5/patient.htmlQuick wins
CI gate — fail a build step when resources diverge:
bash
fhir-resource-diff compare expected.json actual.json --exit-on-diff --quietJSON output for automation:
bash
fhir-resource-diff compare a.json b.json --format jsonIgnore noisy metadata fields:
bash
fhir-resource-diff compare a.json b.json --preset metadataPipe from a FHIR server:
bash
curl -s https://hapi.fhir.org/baseR4/Patient/592473 \
| fhir-resource-diff validate - --fhir-version R4Run from source (contributors)
No build step needed during development:
bash
git clone https://github.com/dnlbox/fhir-resource-diff.git
cd fhir-resource-diff
pnpm install
pnpm cli -- compare examples/patient-a.json examples/patient-b.json
pnpm cli -- validate examples/patient-a.jsonThe -- separator after pnpm cli is required so pnpm passes flags to the script rather than consuming them.
Next steps
- Validate command deep-dive — what it checks, what it skips, JSON output format
- Compare command deep-dive — diff output, --ignore, output formats
- CI/CD integration — GitHub Actions examples, exit codes, quiet mode
- CLI reference — all flags for all commands