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.3.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.3.0
File Size Uploaded Provenance Actions
fhir_linter-1.3.0.tar.gz 295.3 kB With provenance Details for fhir_linter-1.3.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for fhir-linter 1.3.0
File Interpreter ABI Platform Actions
fhir_linter-1.3.0-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details for fhir_linter-1.3.0-cp310-abi3-win_amd64.whl
fhir_linter-1.3.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.3.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
fhir_linter-1.3.0-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details for fhir_linter-1.3.0-cp310-abi3-macosx_11_0_arm64.whl

Total release size: 3.4 MB

Release files / fhir_linter-1.3.0.tar.gz

Download URL fhir_linter-1.3.0.tar.gz
Size 295.3 kB
Tags Source
SHA-256 checksum
How to use checksums
90db3b3651a160a5a93dc24c341d69d900fbf3f9eb7992d9a1c7efd3253397f1
BLAKE2b-256 checksum
How to use checksums
b54fc59c4db22c740c765b9374abcfbf58838122103b8de6e55546111aaa5fdc
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 18, 2026.

Transparency log

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

Download URL fhir_linter-1.3.0-cp310-abi3-win_amd64.whl
Size 949.5 kB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
24c35125a6b0cfad20063ccb2c68107a3220eac13c80ab7db3721359c54b79e2
BLAKE2b-256 checksum
How to use checksums
9d29264133cc9471ef646f381570a8089ea1449d4bd77c388f670f1df2e64427
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 18, 2026.

Transparency log

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

Download URL fhir_linter-1.3.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 1.1 MB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
a9d817b45335fc4a4e1b19ee9075b86a6611469f9552142c38196d4f751bda89
BLAKE2b-256 checksum
How to use checksums
2fd565d87b3a2ebc53de5ac34d303bcaf02e516598209e24f262f7e94fe20e94
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 18, 2026.

Transparency log

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

Download URL fhir_linter-1.3.0-cp310-abi3-macosx_11_0_arm64.whl
Size 1.0 MB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
e518c6dd28bbd05d79c40cb76921372768a3e36342d4c9810371b343faa0ae8e
BLAKE2b-256 checksum
How to use checksums
2e6f6afa8dce3a0d474909bd9563446bf90de456be758d46df689bef18b1976c
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 18, 2026.

Transparency log

Security for fhir-linter 1.3.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.3.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 18, 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