5 unstable releases

Uses new Rust 2024

0.43.2 Jan 23, 2026
0.43.1 Jan 23, 2026
0.43.0 Jan 22, 2026
0.42.0 Jan 6, 2026
0.41.0 Dec 31, 2025

#2700 in Encoding

Download history 30/week @ 2026-01-01 22/week @ 2026-01-08 40/week @ 2026-01-15 74/week @ 2026-01-22 89/week @ 2026-01-29

204 downloads per month

MIT/Apache

1.5MB
27K SLoC

facet-json-schema

Coverage Status crates.io documentation MIT/Apache-2.0 licensed Discord

facet-json-schema

Generate JSON Schema from facet type metadata.

This crate uses facet's reflection capabilities to generate JSON Schema definitions from any type that implements Facet. The generated schemas can be used for:

  • API documentation (OpenAPI/Swagger)
  • Runtime validation
  • Cross-language type generation
  • Editor autocompletion

Usage

use facet::Facet;
use facet_json_schema::to_schema;

#[derive(Facet)]
struct User {
    name: String,
    age: u32,
    email: Option<String>,
}

let schema = to_schema::<User>();
println!("{}", schema);

Output

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "name": { "type": "string" },
    "age": { "type": "integer", "minimum": 0, "maximum": 4294967295 },
    "email": { "type": "string" }
  },
  "required": ["name", "age"]
}

Sponsors

Thanks to all individual sponsors:

GitHub Sponsors Patreon

...along with corporate sponsors:

AWS Zed Depot

...without whom this work could not exist.

Special thanks

The facet logo was drawn by Misiasart.

License

Licensed under either of:

at your option.

Dependencies

~3MB
~53K SLoC