Introducing Gradio Clients


New to Gradio? Start here: Getting Started

See the Release History


import gradio as gr import numpy as np with gr.Blocks() as demo: out = gr.JSON(value={ "Key 1": "Value 1", "Key 2": {"Key 3": "Value 2", "Key 4": "Value 3"}, "Key 5": ["Item 1", "Item 2", "Item 3"], "Key 6": 123, "Key 7": 123.456, "Key 8": True, "Key 9": False, "Key 10": None, "Key 11": np.array([1, 2, 3]), }) demo.launch() numpy


Used to display arbitrary JSON output prettily. As this component does not accept user input, it is rarely used as an input component.


As input component: Passes the JSON value as a dict or list depending on the value.

Your function should accept one of these types:
def predict(
	value: dict | list | None

As output component: Expects a valid JSON str -- or a list or dict that can be serialized to a JSON string. The list or dict value can contain numpy arrays.

Your function should return one of these types:
def predict(ยทยทยท) -> dict | list | str | None
	return value




Class Interface String Shortcut Initialization



Uses default values


from zipfile import ZipFile import gradio as gr def zip_to_json(file_obj): files = [] with ZipFile( as zfile: for zinfo in zfile.infolist(): files.append( { "name": zinfo.filename, "file_size": zinfo.file_size, "compressed_size": zinfo.compress_size, } ) return files demo = gr.Interface(zip_to_json, "file", "json") if __name__ == "__main__": demo.launch()

Event Listeners


Event listeners allow you to respond to user interactions with the UI components you've defined in a Gradio Blocks app. When a user interacts with an element, such as changing a slider value or uploading an image, a function is called.

Supported Event Listeners

The JSON component supports the following event listeners. Each event listener takes the same parameters, which are listed in the Event Parameters table below.

Listener Description

JSON.change(fn, ยทยทยท)

Triggered when the value of the JSON changes either because of user input (e.g. a user types in a textbox) OR because of a function update (e.g. an image receives a value from the output of an event trigger). See .input() for a listener that is only triggered by user input.

Event Parameters