Skip to main content

Build Status PyPI CodSpeed

literalizer

literalizer converts JSON, JSONC, JSON5, YAML, and TOML data structures to native language literal syntax.

Supported languages

Ada, Bash, C, C#, C++, Clojure, COBOL, Common Lisp, Crystal, D, Dart, Dhall, Elixir, Elm, Erlang, F#, Forth, Fortran, Gleam, Go, Groovy, Haskell, Haxe, HCL, Java, JavaScript, JSON5, Jsonnet, Julia, Kotlin, Lua, MATLAB, Mojo, Nim, Nix, Norg, Objective-C, OCaml, Occam-pi, Odin, Perl, PHP, PowerShell, PureScript, Python, R, Racket, Raku, Roc, Ruby, Rust, Scala, Scheme, SML, Swift, SystemVerilog, Tcl, TOML, TypeScript, V, Visual Basic, Wren, YAML, Zig.

Installation

Requires Python 3.12+.

pip install literalizer

Usage

Pass your data, its format, and a target language:

"""Minimal example of using literalizer."""

from literalizer import InputFormat, literalize
from literalizer.languages import Python

result = literalize(
    source='{"x": 1}',
    input_format=InputFormat.JSON,
    language=Python(),
)
# result.code:
# {
#     "x": 1,
# }

Configure the language to control how individual data types are rendered. Comments in the source are preserved using the target language’s comment syntax:

"""Layering format options on top of the minimal call."""

from literalizer import InputFormat, literalize
from literalizer.languages import Go

yaml_config = """\
# Server configuration
host: localhost  # default host
port: 8080
released: 2026-06-02
"""
result = literalize(
    source=yaml_config,
    input_format=InputFormat.YAML,
    language=Go(date_format=Go.date_formats.ISO),
)
# result.code (backslash-t denotes a tab):
# map[string]any{
# \t// Server configuration
# \t"host": "localhost",  // default host
# \t"port": 8080,
# \t"released": "2026-06-02",
# }

Use cases

  • Generate test fixtures from JSON, JSONC, JSON5, YAML, or TOML samples.

  • Generate multi-language request/response examples for API docs (see guide).

  • Generate multi-language function call examples from data (see guide).

  • Create type-safe literal data from JSON, JSONC, JSON5, YAML, or TOML config files.

CLI

A command-line interface is available at literalizer-cli.

Sphinx extension

A Sphinx extension is available at sphinx-literalizer.

Full documentation

See the full documentation for more information including how to contribute.

Metadata

Release files for literalizer 2026.11.5.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for literalizer 2026.11.5.1
File Size Uploaded Provenance Actions
literalizer-2026.11.5.1.tar.gz 12.0 MB With provenance Details for literalizer-2026.11.5.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for literalizer 2026.11.5.1
File Interpreter ABI Platform Actions
literalizer-2026.11.5.1-py3-none-any.whl Python 3 none any Details for literalizer-2026.11.5.1-py3-none-any.whl

Total release size: 13.1 MB

Release files / literalizer-2026.11.5.1.tar.gz

Download URL literalizer-2026.11.5.1.tar.gz
Size 12.0 MB
Tags Source
SHA-256 checksum
How to use checksums
7722ba28e7b1cb5ce8ddb4882c703a7379626b1d47b58a1cf279834d1e3a4027
BLAKE2b-256 checksum
How to use checksums
2fea08d786d1782fba50764fdc9be9775775b5e109f5464b716521e90023abf0
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 5, 2026.

Transparency log

Release files / literalizer-2026.11.5.1-py3-none-any.whl

Download URL literalizer-2026.11.5.1-py3-none-any.whl
Size 1.1 MB
Tags Python 3
SHA-256 checksum
How to use checksums
b4d0bc2784d0f5247141e9432a4fdc0d68317ffaa82f1821d366f7bd0e0e423e
BLAKE2b-256 checksum
How to use checksums
7c9105a50bf9b64de8d6e770c53b6bd0da935cc006bf94afffabae2c2da0e80b
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 5, 2026.

Transparency log

Security for literalizer 2026.11.5.1

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

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for literalizer-2026.11.5.1.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 5, 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.

Release history Release notifications | RSS feed

This release
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