Newsletter
Join the Community
Subscribe to our newsletter for the latest news and updates
Render JSON into collapsible, themeable HTML.
Renderjson is a dependency-free JavaScript library that converts any JSON value into a collapsible, themeable HTML element for interactive inspection.
Renderjson is a small JavaScript library written by David Caldwell that exposes a single renderjson() function. You pass it a JSON value as its sole argument and it returns an HTML element that can be appended to any container on a web page. The library renders the JSON lazily, meaning that initially only a disclosure icon is rendered, and the full nested structure is built only when the user clicks to expand it. This makes the initial render of very large JSON objects extremely fast because the browser does not need to build the entire DOM upfront. The library has no external dependencies and is distributed as a single renderjson.js file.
renderjson.js and no other scripts or styles..disclosure, .syntax, .string, .number, .boolean, .key, .keyword, .object.syntax, and .array.syntax so you can style it with your own CSS.set_icons('+', '-') lets you change the default "⊕" and "⊖" icons to any characters you prefer.set_show_to_level(level) controls how many levels of nested JSON are shown by default; pass the string "all" to expand everything upfront.set_max_string_length(length) truncates strings longer than the given length and makes them expandable; pass "none" to disable truncation.set_sort_objects(true) sorts object keys alphabetically in the rendered output.Renderjson is for front-end developers who need to inspect or display JSON data in the browser. API debuggers can use it to build a quick, interactive view of API responses during development. Documentation site maintainers can embed expandable JSON examples in their pages without pulling in a heavy JSON viewer library. Library authors who need a minimal, dependency-free way to present structured data can integrate Renderjson as a lightweight alternative to building a custom tree view.
To use Renderjson, you include renderjson.js in your page, create a container element, and call renderjson(yourJson) with optional chained configuration, then append the returned element to the container. The library returns an HTML element that you can place anywhere; the lazy rendering engine builds the subtree for each node only when the user clicks its disclosure icon.
No. Renderjson has no external dependencies. You only need to include the single renderjson.js file, and the library will produce an HTML element that you can append to your page.
Yes. Call renderjson.set_icons('+', '-') to replace the default "⊕" and "⊖" disclosure icons with any two strings you want.
Call renderjson.set_show_to_level('all'). This expands the entire JSON tree on initial render, but it removes the benefit of lazy rendering, so it may be slow with very large JSON objects.
Yes. Use renderjson.set_sort_objects(true) to sort object keys alphabetically in the rendered output.
Renderjson is released under the ISC license, and the source code is copyright © 2013-2017 by David Caldwell.
