Convert JSON/dicts into formatted prompt text.
Project description
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")
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file json_to_prompt-0.1.0.tar.gz.
File metadata
- Download URL: json_to_prompt-0.1.0.tar.gz
- Upload date:
- Size: 2.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.3 CPython/3.13.5 Darwin/25.2.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0a04b1319e38216d80a76335f7ba7a6d6654e345dffad4f8154f4fc8e124cf0b
|
|
| MD5 |
aee8d0541075fc8ca70c64af51072007
|
|
| BLAKE2b-256 |
88d3df95252e36468feeefcf4a6456c62900759f6c77a7d4e24cf64636df783b
|
File details
Details for the file json_to_prompt-0.1.0-py3-none-any.whl.
File metadata
- Download URL: json_to_prompt-0.1.0-py3-none-any.whl
- Upload date:
- Size: 3.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.3 CPython/3.13.5 Darwin/25.2.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
26dfbe1d84a02e140083ce5b2fe3dae0596dbdffc9a970e3737da91277f2a3ed
|
|
| MD5 |
2e550a1fc8e3e06f4f6cf48eaf1b2812
|
|
| BLAKE2b-256 |
deb399011054237293490a700bc507fb85f0ad1aac035adf0d2a4a5eee7d5108
|