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.0.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.0.0
File Size Uploaded Provenance Actions
fhir_linter-1.0.0.tar.gz 154.1 kB With provenance Details for fhir_linter-1.0.0.tar.gz

Built distributions (wheels)

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

Total release size: 2.6 MB

Release files / fhir_linter-1.0.0.tar.gz

Download URL fhir_linter-1.0.0.tar.gz
Size 154.1 kB
Tags Source
SHA-256 checksum
How to use checksums
ea15327f553c44564ec6438055b3bf22efaf2b540c52318716226e0f4633da4e
BLAKE2b-256 checksum
How to use checksums
43d0af83c69a0935470d187e2ee5af9261be90d0f24ba867e6fdc77bc5bb47b2
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 12, 2026.

Transparency log

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

Download URL fhir_linter-1.0.0-cp310-abi3-win_amd64.whl
Size 707.0 kB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
1086ebda0d0ba8ec9ec124f5649124c0befa8aa55016a165084c873a9ab89d8c
BLAKE2b-256 checksum
How to use checksums
1277907e6dd0889f2aeacf925d08b41cc1864782bc32b519f6f0840981ee8c32
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 12, 2026.

Transparency log

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

Download URL fhir_linter-1.0.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 896.0 kB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
b92dc516ff3eee9e03a746f15d995b7e6a53d64b9bb97aab5bbbf13d287f3775
BLAKE2b-256 checksum
How to use checksums
f8a6ae46fc26963c0753a4f9db865baa51a9e7cc0e1b87bcd4c0f7843ec1f0aa
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 12, 2026.

Transparency log

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

Download URL fhir_linter-1.0.0-cp310-abi3-macosx_11_0_arm64.whl
Size 803.7 kB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
303ea695c0804bea7cc601e62980151f42e895d92844a38ddd9c4f26ba308363
BLAKE2b-256 checksum
How to use checksums
8bccff07422b56ae64d595a68d7cae590d8049498e7d85420db7136771c0339f
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 12, 2026.

Transparency log

Security for fhir-linter 1.0.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.0.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 12, 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