Skip to main content

fhir-linter

Python bindings for the FHIR R5 linter and validator. Requires Python 3.10+.

pip install fhir-linter

Wheels are built for Linux x86_64 (manylinux2014, glibc 2.17), macOS arm64 and Windows x86_64.

Quick start

import json
import fhir_linter

resource_json = json.dumps({"resourceType": "Patient", "id": "p1"})

for d in fhir_linter.validate(resource_json) + fhir_linter.lint(resource_json):
    print(d.severity, d.code, d.path, d.message)

Both functions take the resource as a JSON string, not a dict. XML input is not supported by the bindings.

FHIR definitions

The wheel does not bundle the FHIR R5 definitions (about 60 MB). Download them once with scripts/download-definitions.sh from the repository, then either pass definitions_dir= to each call or set FHIR_DEFINITIONS_DIR. Without them, calls raise ValueError.

The first call for a directory loads the definitions, which takes a few seconds; later calls in the same process reuse them. Both functions release the GIL, so they can run from several threads.

definitions_dir is read from disk: only pass paths you trust.

API

validate(json, definitions_dir=None) -> list[Diagnostic]

Checks structure, cardinality, types, terminology and invariants (FHIRPath) against the R5 definitions.

lint(json, config_toml=None, definitions_dir=None) -> list[Diagnostic]

Runs the lint rules. config_toml is the content of a fhir-linter.toml file, not a path:

from pathlib import Path

config = Path("fhir-linter.toml").read_text()
diagnostics = fhir_linter.lint(resource_json, config_toml=config)
[rules.narrative-absent]
severity = "error"      # fatal | error | warning | information (hint = information)

[rules.missing-identifier]
enabled = false

Built-in rules, all warning by default:

Rule Code Flags
narrative-absent LINT_001 No narrative text
missing-identifier LINT_002 No identifier
missing-meta-profile LINT_003 No meta.profile

Diagnostic

Read-only object with these attributes:

Attribute Type Meaning
severity str fatal, error, warning or information
code str Stable code, e.g. STRUCTURE_000, INVARIANT_dom-6, LINT_001
message str Human-readable description
path str Element path in the resource
line int | None 1-indexed line
col int | None 1-indexed column, in UTF-8 bytes
offset int | None 0-indexed offset, in UTF-8 bytes
rule str | None Lint rule id; None for validator findings

Locations

col and offset count UTF-8 bytes, not characters: after non-ASCII text such as "ééé", resource_json[d.offset:] lands too far. Index the encoded bytes instead: resource_json.encode()[d.offset:]. line, col and offset are all None without a location.

Errors

  • ValueError: unparsable JSON, invalid lint config, unknown rule, no definitions.
  • RuntimeError: the definitions directory cannot be loaded.

Metadata

Release files for fhir-linter 1.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fhir-linter 1.2.0
File Size Uploaded Provenance Actions
fhir_linter-1.2.0.tar.gz 219.9 kB With provenance Details for fhir_linter-1.2.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for fhir-linter 1.2.0
File Interpreter ABI Platform Actions
fhir_linter-1.2.0-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details for fhir_linter-1.2.0-cp310-abi3-win_amd64.whl
fhir_linter-1.2.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl CPython 3.10 abi3 Linux glibc 2.17+ x86-64 Details for fhir_linter-1.2.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
fhir_linter-1.2.0-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details for fhir_linter-1.2.0-cp310-abi3-macosx_11_0_arm64.whl

Total release size: 2.9 MB

Release files / fhir_linter-1.2.0.tar.gz

Download URL fhir_linter-1.2.0.tar.gz
Size 219.9 kB
Tags Source
SHA-256 checksum
How to use checksums
7ba2bdf3349b0764427abe6e0eebb8ea770139653ead5fff9649bd8168ed2130
BLAKE2b-256 checksum
How to use checksums
e272cab48aff5b5c519d0584922a05f2682076d6441de202b2bb276fd1f4207b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 14, 2026.

Transparency log

Release files / fhir_linter-1.2.0-cp310-abi3-win_amd64.whl

Download URL fhir_linter-1.2.0-cp310-abi3-win_amd64.whl
Size 811.0 kB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
b277adc938bf5bb81a70626e5b09680a4176cbb8899487aba72d0329f9bcc214
BLAKE2b-256 checksum
How to use checksums
2868121b10274bc52fde1d2d6e876e82a6d22f5883165eb6818ba5233b22ec12
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 14, 2026.

Transparency log

Release files / fhir_linter-1.2.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL fhir_linter-1.2.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 1.0 MB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
73676d61eb84cadc1ec7c7ae7240cd61502bb27f3bc3563ec8a3f2a6572ffddc
BLAKE2b-256 checksum
How to use checksums
3c27e75750d0e5e0306df622047ef6dc1f743fa8e8181a38882e35c7d207671d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 14, 2026.

Transparency log

Release files / fhir_linter-1.2.0-cp310-abi3-macosx_11_0_arm64.whl

Download URL fhir_linter-1.2.0-cp310-abi3-macosx_11_0_arm64.whl
Size 903.9 kB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
219da38b7827cfc4d8e6c7e28b3795987a1afa057125d2ee69fa005323c3d096
BLAKE2b-256 checksum
How to use checksums
2e800107534ccc7fb8368b92595e39aed5914ba10d26171989185b4b783b6b3b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 14, 2026.

Transparency log

Security for fhir-linter 1.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 4 files in this release have been uploaded with provenance metadata.

Select from 4 files

Attestation for fhir_linter-1.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 14, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page