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.1.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.1.0
File Size Uploaded Provenance Actions
fhir_linter-1.1.0.tar.gz 197.5 kB With provenance Details for fhir_linter-1.1.0.tar.gz

Built distributions (wheels)

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

Total release size: 2.8 MB

Release files / fhir_linter-1.1.0.tar.gz

Download URL fhir_linter-1.1.0.tar.gz
Size 197.5 kB
Tags Source
SHA-256 checksum
How to use checksums
2d66ae97e076e44fb8f80b744a3b84423dd9cbed19ae8185043f7d4089cf0b80
BLAKE2b-256 checksum
How to use checksums
4dda8cd4f4c990ba893f7c41f22627b46e2e0f7feb0197c3be63c7e0ab8a2253
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.1.0-cp310-abi3-win_amd64.whl

Download URL fhir_linter-1.1.0-cp310-abi3-win_amd64.whl
Size 775.1 kB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
266b4ed0e7049496957662814084d2e0426fbcde9e8b8a172269665c0db08c2d
BLAKE2b-256 checksum
How to use checksums
c793f18ee9b2883dc360276e58a3fe0626c6ec4b65cc0adc5c703c7d1c684500
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.1.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL fhir_linter-1.1.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 972.6 kB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
dfd1aef1f01a30e1543d46b69541aa39121e25d78e48799ea8178886d864664e
BLAKE2b-256 checksum
How to use checksums
4b145280dba82b271ab6dae7d7c30c88b0a557dbf1a94f00aeb1b81e1d355de4
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.1.0-cp310-abi3-macosx_11_0_arm64.whl

Download URL fhir_linter-1.1.0-cp310-abi3-macosx_11_0_arm64.whl
Size 869.4 kB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
bc8ad9c37384b4da7f20e9d92a2428c32c5c240c11c581f280084acf1447e81f
BLAKE2b-256 checksum
How to use checksums
04edc2849bd9c6fa8d39a4ac84e6012cb3158a5632c27796876c63a367c80436
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.1.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.1.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