Registry / serialization / stix2-validator

stix2-validator

JSON →
library3.3.1pypypi✓ verified 83d ago

The stix2-validator library provides APIs and scripts for validating STIX 2.x documents against the official STIX specifications. It is currently at version 3.2.0 and receives regular updates, typically with minor releases addressing fixes and dependency updates, and less frequent major releases for specification updates and significant feature enhancements.

pip install stix2-validator
INSTALL
IMPORT
SIG · STIX2-VALIDATOR
S
stix2-validator
serializationpythonv3.3.1
Install
5.5s avg
Import
Disk
38MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v3.3.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 39.6MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 5.5s · import 0.000s · 40MB
38MB installed
● package 38MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

validate
from stix2validator import validate
from stix2validator import Validator
ValidationError
from stix2validator import ValidationError
ValidationOptions
from stix2validator import ValidationOptions

This quickstart demonstrates how to initialize the `Validator` and use it to validate a STIX object represented as a Python dictionary. It shows both standard and verbose validation output. To validate a STIX document from a file, load its JSON content into a dictionary first.

from stix2validator import Validator import json # Example STIX 2.1 Indicator object for validation stix_object = { "type": "indicator", "spec_version": "2.1", "id": "indicator--a79f0462-8789-4b67-8c0c-52643a2d1d07", "created": "2024-01-01T12:00:00.000Z", "modified": "2024-01-01T12:00:00.000Z", "pattern": "[file:hashes.MD5 = 'd41d8cd98f00b204e9800998ecf8427e']", "pattern_type": "stix", "valid_from": "2024-01-01T12:00:00.000Z" } # Initialize the validator validator = Validator() # Validate a STIX dictionary (e.g., loaded from JSON) results = validator.validate(stix_object) if not results: print("STIX object is valid.") else: print("STIX object has validation issues:") for result in results: print(f" - {result}") # For more detailed output, instantiate with verbose=True verbose_validator = Validator(verbose=True) verbose_results = verbose_validator.validate(stix_object) if verbose_results: print("\nVerbose validation results:") for result in verbose_results: print(f" - {result}")
stix2-validator --version
Debug
Known issues
breakingPython 3.5 and 3.6 are no longer supported. Version 3.0.0 dropped support for Python 3.5, and version 3.1.0 dropped support for Python 3.6.
fix
Upgrade your Python environment to 3.7 or newer to use stix2-validator versions 3.0.0+.
affects: >=3.0.0
breakingThe `network-traffic.http-request-ext.request_header` property must now be a list of strings. Previously, it could be a singular string, which is no longer compliant.
fix
Ensure that `request_header` values within network-traffic extension objects are provided as a list of strings, even if only one header is present (e.g., `['Host: example.com']`).
affects: >=3.2.0
gotchaWhen validating STIX documents against older specification versions, or documents that mix object `spec_version` values, the validator might default to the latest specification rules. Explicitly configure `stix_version` if you encounter unexpected errors for older STIX documents.
fix
When initializing `Validator` or calling `validate()`, specify the `stix_version` parameter (e.g., `Validator(stix_version='2.0')` or `validator.validate(obj, stix_version='2.0')`) to ensure validation against the correct STIX specification version.
affects: All
deprecatedOlder versions of `jsonschema` used by `stix2-validator` might log deprecation warnings related to `jsonschema.draft202012_format_checker` due to changes in `jsonschema` itself.
fix
Upgrade `stix2-validator` to version 3.1.3 or newer, which includes fixes to address these `jsonschema` deprecation warnings by updating internal schema references.
affects: <3.1.3
Upgrade
Version history
3.3.1latest on PyPI · released May 12, 2026
Audit
Dependencies
jsonschemarequiredCore dependency for schema validation, frequently updated.
attrsrequiredUtility library, updated in 3.1.4 to resolve dependency issues.
Agent activity
18 hits · last 30 days
node
14
Amazon
1
OpenAI (training)
1
Resources
stix2-validator — pip install stix2-validator · libregistry