Home
| Colors: |
February 2026

Pretty Print MiniJinja Data as JSON

Use the built-in tojson filter and pass it a true argument to pretty print MiniJinja data as JSON.

{{ some_data|tojson(true) }}

or, with alternate tokens:

[@ some_data|tojson(true) @]

The indent size sets to two spaces. You can also pass an index=# argument to set the spacing:

{{ some_data|tojson(indent=4) }}

or, with alternate tokens:

[@ some_data|tojson(indent=4) @]

There are a bunch more MiniJinja filters if you're into that kinda thing.

-a

end of line

Endnotes

I set up my minijinja engines to use [@ @] instead of {{ }}. It's easier for me to track them on the page.