Skip to content

CLI reference

Complete flag reference for all fhir-resource-diff commands.

compare

Compare two FHIR resources field by field.

fhir-resource-diff compare <file-a> <file-b> [options]
Argument / FlagTypeDefaultDescription
file-apath or -requiredFirst resource file, or - to read from stdin
file-bpath or -requiredSecond resource file, or - to read from stdin
--format <fmt>text | json | markdowntextOutput format
--fhir-version <ver>R4 | R4B | R5auto-detect or R4FHIR version for validation and doc links
--ignore <paths>comma-separatedDot-notation paths to exclude from comparison (e.g. meta.lastUpdated,id)
--preset <name>metadata | clinical | strictNamed set of paths to ignore
--normalize <name>canonical | noneApply normalization before comparing
--exit-on-diffflagfalseExit 1 when differences are found (for CI gates)
--quietflagfalseSuppress all stdout output
--envelopeflagfalseWrap JSON output in metadata envelope (requires --format json)
--forceflagfalseProceed even when comparing resources of different types

Presets:

PresetIgnored paths
metadataid, meta.lastUpdated, meta.versionId, meta.tag, text
clinicalSame as metadata plus narrative text fields
strictNo ignores — every field compared

validate

Validate a FHIR resource for format and structural correctness.

fhir-resource-diff validate <file> [options]
Argument / FlagTypeDefaultDescription
filepath or -requiredResource file, or - to read from stdin
--format <fmt>text | jsontextOutput format
--fhir-version <ver>R4 | R4B | R5auto-detect or R4FHIR version for registry checks and doc links
--quietflagfalseSuppress all stdout output
--envelopeflagfalseWrap JSON output in metadata envelope (requires --format json)

normalize

Normalize a FHIR resource to a canonical form.

fhir-resource-diff normalize <file> [options]
Argument / FlagTypeDefaultDescription
filepath or -requiredResource file, or - to read from stdin
--preset <name>canonical | nonecanonicalNormalization preset
--fhir-version <ver>R4 | R4B | R5auto-detect or R4FHIR version
--output <path>file pathstdoutWrite normalized output to a file instead of stdout
--quietflagfalseSuppress stdout output

info

Look up a FHIR resource type and get HL7 documentation links.

fhir-resource-diff info <resourceType> [options]
Argument / FlagTypeDefaultDescription
resourceTypestringrequiredFHIR resource type name (e.g. Patient, Observation)
--fhir-version <ver>R4 | R4B | R5allShow docs link for a specific version only
--format <fmt>text | jsontextOutput format

list-resources

List known FHIR resource types from the registry.

fhir-resource-diff list-resources [options]
FlagTypeDefaultDescription
--fhir-version <ver>R4 | R4B | R5allFilter to types available in a specific version
--category <cat>see belowallFilter by resource category
--format <fmt>text | jsontextOutput format

Categories: foundation, base, clinical, financial, specialized, conformance

Common patterns

bash
# Validate with explicit version
fhir-resource-diff validate resource.json --fhir-version R4

# Compare with metadata preset and CI exit code
fhir-resource-diff compare expected.json actual.json \
  --preset metadata --exit-on-diff --quiet

# Compare with JSON output and envelope
fhir-resource-diff compare a.json b.json \
  --format json --envelope --fhir-version R4

# Pipe from stdin
curl -s https://hapi.fhir.org/baseR4/Patient/1 \
  | fhir-resource-diff validate - --fhir-version R4

# Ignore specific fields
fhir-resource-diff compare a.json b.json \
  --ignore meta.lastUpdated,meta.versionId,id,text

Version flag

Use -V to print the CLI version number:

bash
fhir-resource-diff -V

The long form --version is intentionally not registered at root level — this prevents Commander from intercepting --version before subcommand parsers can see it. If you pass --version to a subcommand (e.g. list-resources --version R4), you will get an "unknown option" error rather than silently printing the version number. Use --fhir-version for subcommand version filtering.

FHIR version strings

The --fhir-version flag accepts these values (case-insensitive):

AcceptedResolves to
R4, r4, 4.0.1R4
R4B, r4b, 4.3.0R4B
R5, r5, 5.0.0R5

Released under the MIT License.