Show API reference for

Display object or string as a pretty-printed JSON string.

Function signature[source]

st.json(body, *, expanded=True)

Parameters

body (object or str)

The object to print as JSON. All referenced objects should be serializable to JSON as well. If object is a string, we assume it contains serialized JSON.

expanded (bool)

An optional boolean that allows the user to set whether the initial state of this json element should be expanded. Defaults to True. This argument can only be supplied by keyword.

Example

import streamlit as st

st.json({
    'foo': 'bar',
    'baz': 'boz',
    'stuff': [
        'stuff 1',
        'stuff 2',
        'stuff 3',
        'stuff 5',
    ],
})
star

Tip

Want a new st.json feature or found a bug? Browse open issues and react with a 👍 on the initial post of the ones that matter to you. Your votes help us prioritize what to work on next.

forum

Still have questions?

Our forums are full of helpful information and Streamlit experts.