Skip to main content

JSON To Prompt

A lightweight Python utility for converting structured JSON data into formatted prompt text.

This library is designed to transform dictionaries or JSON inputs into readable, structured text prompts suitable for LLM workflows, templating systems, or downstream processing.

Features

  • Convert Python dictionaries to formatted prompt strings
  • Read JSON strings directly
  • Load JSON from file
  • Write generated prompts to file

Usage

Convert a Dictionary to a Prompt

from json_to_prompt import JSONToPrompt

data = {
    "Title": "Hello...",
    "Subtitle": "Goodbye...",
    "Cards": [
        {
            "ID": 1,
            "Title": "I'm a card...",
        }
    ]
}

jtp = JSONToPrompt(debug=True)
prompt = jtp.add_dict(data).parse().get_prompt()
print([prompt])

Output:

Title: Hello...
Subtitle: Goodbye...
Cards:
    - ID: 1
    - Title: I'm a card... 

Read from a JSON string

json_str = '{"pet": "cat"}'

jtp = JSONToPrompt()
prompt = jtp.read_json(json_str).parse().get_prompt()

Read from a JSON file

jtp = JSONToPrompt()
prompt = jtp.read_json_file("example.json").parse().get_prompt()

Write Prompt To file

jtp.write_prompt_to_file("prompt.txt")

Metadata

Release files for json-to-prompt 0.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 json-to-prompt 0.1.0
File Size Uploaded
json_to_prompt-0.1.0.tar.gz 2.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for json-to-prompt 0.1.0
File Interpreter ABI Platform
json_to_prompt-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 6.1 kB

Release files / json_to_prompt-0.1.0.tar.gz

Download URL json_to_prompt-0.1.0.tar.gz
Size 2.7 kB
Tags Source
SHA-256 checksum
How to use checksums
0a04b1319e38216d80a76335f7ba7a6d6654e345dffad4f8154f4fc8e124cf0b
BLAKE2b-256 checksum
How to use checksums
88d3df95252e36468feeefcf4a6456c62900759f6c77a7d4e24cf64636df783b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.3 CPython/3.13.5 Darwin/25.2.0

Release files / json_to_prompt-0.1.0-py3-none-any.whl

Download URL json_to_prompt-0.1.0-py3-none-any.whl
Size 3.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
26dfbe1d84a02e140083ce5b2fe3dae0596dbdffc9a970e3737da91277f2a3ed
BLAKE2b-256 checksum
How to use checksums
deb399011054237293490a700bc507fb85f0ad1aac035adf0d2a4a5eee7d5108
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.3 CPython/3.13.5 Darwin/25.2.0

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

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