Skip to content
animorio
IT
Back to the library

JSON tree viewer

Text, HoverGSAP, CSS onlyMediumCompressed weight: Demo 6.1 KBGSAP 28 KBFreeDownload the zip

The JSON viewer of a developer tool: branches open on a spring, every value has its type’s colour and a closed branch says how many keys it holds. Hover a row and the keys above it light up, the branch’s guide glows and the bar below writes the path, copied with one tap.

The code

A folder that runs on its own: index.html, style.css, script.js and the libraries from a CDN. The React and Vue tabs hold the same demo as a ready component, which switches its animations off when it leaves the page.

<!doctype html>
<!--
  "JSON tree viewer" from Animorio · https://animorio.com
  License: free on your own sites and your clients’ sites, paid work included.
  Not for resale, redistribution, templates or code collections · https://animorio.com/en/license/
-->
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>JSON tree viewer</title>
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource-variable/mona-sans@5.3.0/wdth.css">
  <link rel="stylesheet" href="style.css">
</head>
<body>
  <main class="stage">
    <!-- a JSON viewer: branches open on a spring, every value has the colour of its type, a closed branch
         says how many keys it holds, and the bar below writes the path of the row being read -->
    <section class="jv" data-jv aria-label="JSON viewer">
      <header class="jv__head">
        <span class="jv__file">order.json</span>
        <span class="jv__meta" data-meta></span>
      </header>
      <div class="jv__tree" data-tree role="tree" aria-label="order.json"></div>
      <footer class="jv__bar">
        <span class="jv__path" data-path aria-live="polite"></span>
        <span class="jv__roll jv__copy"><span data-copy>Click to copy</span></span>
      </footer>
    </section>

    <svg class="ghost" data-ghost viewBox="0 0 24 24" aria-hidden="true"><path d="M5 3.200 19.200 11l-6.300 1.600-3.300 5.900Z"></path></svg>
  </main>

  <script src="https://cdn.jsdelivr.net/npm/gsap@3.15.0/dist/gsap.min.js"></script>
  <script src="script.js"></script>
</body>
</html>

Playground

Change values, colours and text with the controls and watch the animation respond live. Or write in the code yourself. Then download the folder with your changes.

15 values to change

Works with Claude, Claude Code, ChatGPT, Cursor, VS Code, Windsurf, Codex, Gemini CLI

Or ask your AI assistant for it

With the Animorio connector, Claude Code, ChatGPT, Cursor or VS Code take it from here, guide included, and fit it into your project. Paste this request:

Take “JSON tree viewer” from Animorio and fit it into my site
Platform licenseFree on your sites and your clients’ sites. Want it inside a website builder, a template platform or a client dashboard? There’s a license for agencies and platforms.

What it does

On black, a dark card: on top “order.json” and its size in bytes, in the middle the tree, at the bottom a bar with the path. The tree shows an order: keys in light, strings green, numbers amber, booleans violet, null in grey; “customer” and the two elements of “items” are closed, with a small arrow and a label saying how many keys they hold, “{ 2 }”. Tap a branch and the arrow turns, the height opens with a small bounce and the rows inside come in one after the other from the left; a thin vertical line acts as a guide. Hover a row and it takes a background, the keys of the branches holding it turn cyan, the guide lights up and the bar below writes the path piece by piece, “$.items[1].sku”, with the last piece in light. Tap a value and the path is copied: the row gives a jolt and “Path copied” rolls in on the right. On a keyboard the up and down arrows walk the visible rows and Enter opens or copies.

How it works

The tree is born from the data

A recursive function reads the object and makes one row per key; for objects and arrays it adds a container for the children. Each row knows its path and its parent: change the data at the top of the script and the tree redraws.

Opening is measuring

The children’s container goes from zero to its real height, measured by setting height auto for an instant; GSAP gets there with a bounce and puts auto back at the end, so a branch opened inside another makes it grow by itself.

The path climbs the parents

Reading a row climbs from parent to parent: each takes the class that colours its key and lights its guide. The pieces of the path are already stored on the row, so the bar writes them without any work.

Closed means inert

A closed branch has the inert attribute: its rows cannot take focus and screen readers skip them. Rows are buttons with aria-expanded.

Values to change

NameFileDefaultWhat it changes
ACCENTscript.js#5ad4e6The colour of the path: the keys above the row being read and the branch’s guide.
INDENTscript.js18How many pixels each level of the tree is indented.
SPRINGscript.js1How much a branch bounces as it opens: 0 = none, 2 = a lot.
LOOPscript.jstrueLeft alone, the demo’s pointer opens two branches, reads and copies a path.

Try them in the Playground

When to use it

In an API’s documentation, in the panel of an app showing a call’s response, in a logging or debugging tool. The same tree with a path suits nested settings, a configuration file, a catalogue’s categories.

On phones

The same card, as wide as the screen; the tree has a fixed height and scrolls inside itself when every branch is open. A finger’s tap reads the row and opens the branch or copies the path.

With reduced motion

Branches open and close at once, rows do not slide and the path appears already written. The demo does not move by itself.

Pitfalls

  • Order, customer and products are made up.
  • Height cannot be animated to “auto”: measure it, get there in pixels and only at the end put auto back, or a branch opened inside would stay clipped.
  • The height’s bounce overshoots the real size for a moment: the container has hidden overflow and the rows below move with it, so the overshoot reads as a breath, not a jump.
  • Copying to the clipboard can be refused by the browser (insecure page, iframe): “Path copied” should not hang on it and block the interface, but a real product says when it failed.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

Compressed with gzip, the three demo files weigh 6.1 KB; the libraries: GSAP 28 KB.

Testing

Tested on 20 November 2026

  • Desktop: Done
  • Phone: Done
  • Reduced motion: Done
  • Safari on iPhone: To do

License

Use it in your own projects and in your clients’ projects. Do not resell it or redistribute it as is. GSAP stays under its own Standard license. Full license.

All animations