llm-prettier 0.1.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- llm_prettier-0.1.1/.gitignore +30 -0
- llm_prettier-0.1.1/LICENSE +21 -0
- llm_prettier-0.1.1/PKG-INFO +131 -0
- llm_prettier-0.1.1/README.md +90 -0
- llm_prettier-0.1.1/llm_prettier/__init__.py +57 -0
- llm_prettier-0.1.1/llm_prettier/assets/__init__.py +2 -0
- llm_prettier-0.1.1/llm_prettier/assets/script.js +401 -0
- llm_prettier-0.1.1/llm_prettier/assets/style.css +506 -0
- llm_prettier-0.1.1/llm_prettier/assets/template.html +53 -0
- llm_prettier-0.1.1/llm_prettier/cli.py +143 -0
- llm_prettier-0.1.1/llm_prettier/core.py +55 -0
- llm_prettier-0.1.1/pyproject.toml +40 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
*.so
|
|
6
|
+
*.egg
|
|
7
|
+
*.egg-info/
|
|
8
|
+
dist/
|
|
9
|
+
build/
|
|
10
|
+
.eggs/
|
|
11
|
+
|
|
12
|
+
# Virtual environments
|
|
13
|
+
.venv/
|
|
14
|
+
venv/
|
|
15
|
+
env/
|
|
16
|
+
|
|
17
|
+
# Generated viewer files
|
|
18
|
+
viewer_*.html
|
|
19
|
+
|
|
20
|
+
# IDE / editor
|
|
21
|
+
.vscode/
|
|
22
|
+
.idea/
|
|
23
|
+
*.swp
|
|
24
|
+
*.swo
|
|
25
|
+
.DS_Store
|
|
26
|
+
|
|
27
|
+
# Testing
|
|
28
|
+
.pytest_cache/
|
|
29
|
+
.coverage
|
|
30
|
+
htmlcov/
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Amaruki
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: llm-prettier
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: A generic JSON prettier and interactive HTML viewer, built especially for parsing embedded JSON from LLM payloads and responses.
|
|
5
|
+
Project-URL: Homepage, https://github.com/amaruki/llm-prettier
|
|
6
|
+
Project-URL: Repository, https://github.com/amaruki/llm-prettier
|
|
7
|
+
Project-URL: Issues, https://github.com/amaruki/llm-prettier/issues
|
|
8
|
+
Author-email: Amaruki <krilinamar@gmail.com>
|
|
9
|
+
License: MIT License
|
|
10
|
+
|
|
11
|
+
Copyright (c) 2026 Amaruki
|
|
12
|
+
|
|
13
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
14
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
15
|
+
in the Software without restriction, including without limitation the rights
|
|
16
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
17
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
18
|
+
furnished to do so, subject to the following conditions:
|
|
19
|
+
|
|
20
|
+
The above copyright notice and this permission notice shall be included in all
|
|
21
|
+
copies or substantial portions of the Software.
|
|
22
|
+
|
|
23
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
24
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
25
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
26
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
27
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
28
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
29
|
+
SOFTWARE.
|
|
30
|
+
License-File: LICENSE
|
|
31
|
+
Keywords: ai,anthropic,debug,gemini,json,llm,openai,prettier,viewer
|
|
32
|
+
Classifier: Development Status :: 4 - Beta
|
|
33
|
+
Classifier: Intended Audience :: Developers
|
|
34
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
35
|
+
Classifier: Operating System :: OS Independent
|
|
36
|
+
Classifier: Programming Language :: Python :: 3
|
|
37
|
+
Classifier: Topic :: Software Development :: Debuggers
|
|
38
|
+
Classifier: Topic :: Utilities
|
|
39
|
+
Requires-Python: >=3.8
|
|
40
|
+
Description-Content-Type: text/markdown
|
|
41
|
+
|
|
42
|
+
# llm-prettier
|
|
43
|
+
|
|
44
|
+
A simple, generic JSON prettier and interactive HTML viewer with a killer feature for developers working with LLM APIs: it automatically detects and parses **embedded stringified JSON**, rendering it as a full interactive tree rather than a raw escaped string.
|
|
45
|
+
|
|
46
|
+
## Features
|
|
47
|
+
|
|
48
|
+
- π² **Interactive tree view** β Collapsible nodes for any JSON structure
|
|
49
|
+
- π **Search & filter** β `Ctrl+F` search that highlights matching keys/values with `Enter`/`Shift+Enter` navigation
|
|
50
|
+
- π **Copy to clipboard** β Hover any value or key to copy it; click any key to copy its full JSON path
|
|
51
|
+
- πΊοΈ **JSON path breadcrumb** β Displays the full path (e.g. `$.choices[0].message.content`) on key click
|
|
52
|
+
- π **Stats bar** β Shows total key count, max depth, and data size at a glance
|
|
53
|
+
- π’ **Depth controls** β Collapse to depth D2, D3, D4 in addition to expand/collapse all
|
|
54
|
+
- πͺ‘ **Embedded JSON parsing** β Automatically detects and renders stringified JSON, including JSON inside Markdown code blocks (`json ... `) and XML tags (`<tool_call> ... </tool_call>`)
|
|
55
|
+
- π‘ **Fully local** β No external dependencies; everything runs in-browser from a single HTML file
|
|
56
|
+
|
|
57
|
+
## Installation
|
|
58
|
+
|
|
59
|
+
Using `pip`:
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
pip install llm-prettier
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Using `uv` (faster):
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
uv pip install llm-prettier
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
After installing, the `llm-prettier` CLI will be available.
|
|
72
|
+
|
|
73
|
+
## Usage
|
|
74
|
+
|
|
75
|
+
### CLI Tool
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
# Prettify a JSON file (saves as viewer_<name>.html)
|
|
79
|
+
llm-prettier path/to/response.json
|
|
80
|
+
|
|
81
|
+
# Open in browser immediately via local server
|
|
82
|
+
llm-prettier path/to/response.json --serve
|
|
83
|
+
|
|
84
|
+
# Specify custom output file
|
|
85
|
+
llm-prettier path/to/response.json -o my_output.html
|
|
86
|
+
|
|
87
|
+
# Read from stdin
|
|
88
|
+
cat response.json | llm-prettier -
|
|
89
|
+
curl https://api.example.com/data | llm-prettier - --serve
|
|
90
|
+
|
|
91
|
+
# Custom server port
|
|
92
|
+
llm-prettier response.json --serve --port 8080
|
|
93
|
+
|
|
94
|
+
# Print version
|
|
95
|
+
llm-prettier --version
|
|
96
|
+
|
|
97
|
+
# Run it without installing globally
|
|
98
|
+
uv run llm-prettier response.json --serve
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### Python API
|
|
102
|
+
|
|
103
|
+
```python
|
|
104
|
+
import llm_prettier
|
|
105
|
+
|
|
106
|
+
my_data = {
|
|
107
|
+
"model": "gemini-flash",
|
|
108
|
+
"message": {
|
|
109
|
+
"content": "{\"tool_call\": {\"temperature\": 0.8}}"
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
# Generate HTML string
|
|
114
|
+
html_str = llm_prettier.render_html(my_data, title="My LLM Response")
|
|
115
|
+
|
|
116
|
+
# Save to file; returns the absolute path on success
|
|
117
|
+
out_path = llm_prettier.show(my_data, out_name="viewer_mydata.html")
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## Viewer Keyboard Shortcuts
|
|
121
|
+
|
|
122
|
+
| Key | Action |
|
|
123
|
+
| ------------- | --------------------- |
|
|
124
|
+
| `Ctrl+F` | Focus search bar |
|
|
125
|
+
| `Enter` | Next search match |
|
|
126
|
+
| `Shift+Enter` | Previous search match |
|
|
127
|
+
| `Escape` | Clear search |
|
|
128
|
+
|
|
129
|
+
## License
|
|
130
|
+
|
|
131
|
+
[MIT](LICENSE)
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# llm-prettier
|
|
2
|
+
|
|
3
|
+
A simple, generic JSON prettier and interactive HTML viewer with a killer feature for developers working with LLM APIs: it automatically detects and parses **embedded stringified JSON**, rendering it as a full interactive tree rather than a raw escaped string.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- π² **Interactive tree view** β Collapsible nodes for any JSON structure
|
|
8
|
+
- π **Search & filter** β `Ctrl+F` search that highlights matching keys/values with `Enter`/`Shift+Enter` navigation
|
|
9
|
+
- π **Copy to clipboard** β Hover any value or key to copy it; click any key to copy its full JSON path
|
|
10
|
+
- πΊοΈ **JSON path breadcrumb** β Displays the full path (e.g. `$.choices[0].message.content`) on key click
|
|
11
|
+
- π **Stats bar** β Shows total key count, max depth, and data size at a glance
|
|
12
|
+
- π’ **Depth controls** β Collapse to depth D2, D3, D4 in addition to expand/collapse all
|
|
13
|
+
- πͺ‘ **Embedded JSON parsing** β Automatically detects and renders stringified JSON, including JSON inside Markdown code blocks (`json ... `) and XML tags (`<tool_call> ... </tool_call>`)
|
|
14
|
+
- π‘ **Fully local** β No external dependencies; everything runs in-browser from a single HTML file
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
Using `pip`:
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
pip install llm-prettier
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Using `uv` (faster):
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
uv pip install llm-prettier
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
After installing, the `llm-prettier` CLI will be available.
|
|
31
|
+
|
|
32
|
+
## Usage
|
|
33
|
+
|
|
34
|
+
### CLI Tool
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
# Prettify a JSON file (saves as viewer_<name>.html)
|
|
38
|
+
llm-prettier path/to/response.json
|
|
39
|
+
|
|
40
|
+
# Open in browser immediately via local server
|
|
41
|
+
llm-prettier path/to/response.json --serve
|
|
42
|
+
|
|
43
|
+
# Specify custom output file
|
|
44
|
+
llm-prettier path/to/response.json -o my_output.html
|
|
45
|
+
|
|
46
|
+
# Read from stdin
|
|
47
|
+
cat response.json | llm-prettier -
|
|
48
|
+
curl https://api.example.com/data | llm-prettier - --serve
|
|
49
|
+
|
|
50
|
+
# Custom server port
|
|
51
|
+
llm-prettier response.json --serve --port 8080
|
|
52
|
+
|
|
53
|
+
# Print version
|
|
54
|
+
llm-prettier --version
|
|
55
|
+
|
|
56
|
+
# Run it without installing globally
|
|
57
|
+
uv run llm-prettier response.json --serve
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Python API
|
|
61
|
+
|
|
62
|
+
```python
|
|
63
|
+
import llm_prettier
|
|
64
|
+
|
|
65
|
+
my_data = {
|
|
66
|
+
"model": "gemini-flash",
|
|
67
|
+
"message": {
|
|
68
|
+
"content": "{\"tool_call\": {\"temperature\": 0.8}}"
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
# Generate HTML string
|
|
73
|
+
html_str = llm_prettier.render_html(my_data, title="My LLM Response")
|
|
74
|
+
|
|
75
|
+
# Save to file; returns the absolute path on success
|
|
76
|
+
out_path = llm_prettier.show(my_data, out_name="viewer_mydata.html")
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Viewer Keyboard Shortcuts
|
|
80
|
+
|
|
81
|
+
| Key | Action |
|
|
82
|
+
| ------------- | --------------------- |
|
|
83
|
+
| `Ctrl+F` | Focus search bar |
|
|
84
|
+
| `Enter` | Next search match |
|
|
85
|
+
| `Shift+Enter` | Previous search match |
|
|
86
|
+
| `Escape` | Clear search |
|
|
87
|
+
|
|
88
|
+
## License
|
|
89
|
+
|
|
90
|
+
[MIT](LICENSE)
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"""llm-prettier: A JSON prettier and interactive HTML viewer for LLM payloads."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Any, Optional
|
|
6
|
+
|
|
7
|
+
import llm_prettier.core as core
|
|
8
|
+
|
|
9
|
+
__version__ = "0.1.0"
|
|
10
|
+
__all__ = ["render_html", "show", "__version__"]
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def render_html(data: Any, title: str = "LLM Prettier Output") -> str:
|
|
14
|
+
"""
|
|
15
|
+
Renders the provided dictionary/JSON data to a prettified interactive HTML tree.
|
|
16
|
+
|
|
17
|
+
Args:
|
|
18
|
+
data: The dictionary, list, or other JSON-serializable value to render.
|
|
19
|
+
title: The title shown in the browser tab and page header.
|
|
20
|
+
|
|
21
|
+
Returns:
|
|
22
|
+
A string containing the full HTML document.
|
|
23
|
+
"""
|
|
24
|
+
return core.build_template(data, title)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def show(
|
|
28
|
+
data: Any,
|
|
29
|
+
out_name: str = "viewer_output.html",
|
|
30
|
+
title: Optional[str] = None,
|
|
31
|
+
) -> Optional[str]:
|
|
32
|
+
"""
|
|
33
|
+
Renders the JSON data to an interactive HTML file and saves it to disk.
|
|
34
|
+
|
|
35
|
+
Args:
|
|
36
|
+
data: The dictionary or list to render.
|
|
37
|
+
out_name: The output filename. Default is 'viewer_output.html'.
|
|
38
|
+
title: The title of the HTML page. If None, derived from out_name.
|
|
39
|
+
|
|
40
|
+
Returns:
|
|
41
|
+
The absolute path to the written file on success, or None on failure.
|
|
42
|
+
"""
|
|
43
|
+
import os
|
|
44
|
+
|
|
45
|
+
if title is None:
|
|
46
|
+
title = out_name
|
|
47
|
+
|
|
48
|
+
html = render_html(data, title)
|
|
49
|
+
try:
|
|
50
|
+
with open(out_name, "w", encoding="utf-8") as f:
|
|
51
|
+
f.write(html)
|
|
52
|
+
abs_path = os.path.abspath(out_name)
|
|
53
|
+
print(f"[SUCCESS] Generated {abs_path}")
|
|
54
|
+
return abs_path
|
|
55
|
+
except Exception as e:
|
|
56
|
+
print(f"[ERROR] Could not save {out_name}: {e}")
|
|
57
|
+
return None
|