Showify
Arguably the most comprehensive library for stringifying any JavaScript value into a human-readable format, handling nearly every scenario you might encounter.
Install / Use
/learn @Snowflyt/ShowifyREADME

Features
- Stringify any JavaScript value in a format similar to
util.inspectin Node.js. Special cases like Map, Set, array empty slots, wrapper objects for primitives, ArrayBuffer, DataView, WeakMap, WeakSet, and more are handled properly. - Support for maximum recursion depth in nested objects.
- Circular references displayed with a reference pointer (e.g.,
<ref *1> { foo: { bar: [Circular *1] } }) instead of just[Circular]. - Auto indentation and line breaking for long outputs, just like
console.log/util.inspectin Node.js and Deno. - ANSI color support.
- Highly customizable options for indentation, quote style, hidden properties, colors, and more.
- Custom serializers for your own types, with a user-friendly API that works on a tree-like structure instead of raw strings, handling maximum recursion depth, indentation, and circular references automatically — without any extra effort.
Quickstart
Simply import the show function and use it to stringify any JavaScript value:
import { show } from "showify";
const value = {
foo: "bar",
"Hello\nworld": [-0, 2n, NaN],
[Symbol("qux")]: { quux: "corge" },
map: new Map([
["foo", "bar"],
[{ bar: 42 }, "qux"],
]),
};
value.circular = value;
console.log(show(value, { indent: 2, trailingComma: "auto", colors: true }));
// <ref *1> {
// foo: "bar",
// "Hello\nworld": [-0, 2n, NaN],
// map: Map(2) { "foo" => "bar", { bar: 42 } => "qux" },
// circular: [Circular *1],
// Symbol(qux): { quux: "corge" },
// }
The show() function accepts an optional second argument for options. Some common options are listed here:
depth: Maximum recursion depth, defaults toInfinity.indent: Number of spaces to indent, defaults to0. To enable indentation and auto line breaking, setindentto a positive integer, e.g.,2.breakLength: Maximum line length before breaking, defaults to80. This option is ignored ifindentis0.sorted: Whether to sort the keys of objects (includingMaps andSets) in the resulting string, defaults tofalse.quoteStyle: Preferred quote style for strings, should be"single","double","backtick", or an array of them to try in order, defaults to["double", "single", "backtick"].trailComma: Whether to add a trailing comma to the last element of an array or object, should be"none","always"or"auto"(add trailing comma only when the last item is on a separate line), defaults to"none".colors: Enable ANSI colors, defaults tofalse.
showify supports many other options. For a complete list of options, see the available options section below.
Note that showify uses slightly different default options compared to util.inspect in Node.js. If you want to achieve the exactly same default output as util.inspect in Node.js, see the related FAQ.
Installation
To install showify via npm (or any other package manager you prefer):
npm install showify
If you prefer a lightweight version with a smaller bundle size, you may also consider @showify/lite, which removes ANSI color support and several other features that are not needed for most use cases.
Comparison
Here’s a comparison of the features of showify, util.inspect in Node.js, and other libraries:
- ✅ 1st-class, built-in, and ready to use with no additional configuration or code.
- 🟡 Supported, but has limitations or is not as complete as showify.
- 🔶 Supported and documented, but not out-of-the-box or requires extra user-code to implement.
- ❌ Not officially supported or documented.
| Feature | showify | util.inspect | pretty-format | object-inspect | stringify-object |
| ------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Bundle size | <a href="https://bundlephobia.com/package/showify"><img src="https://img.shields.io/bundlephobia/minzip/showify.svg" alt="minzipped size" height="18"></a> | ❓ | <a href="https://bundlephobia.com/package/pretty-format"><img src="https://img.shields.io/bundlephobia/minzip/pretty-format.svg" alt="minzipped size" height="18"></a> | <a href="https://bundlephobia.com/package/object-inspect"><img src="https://img.shields.io/bundlephobia/minzip/object-inspect.svg" alt="minzipped size" height="18"></a> | <a href="https://bundlephobia.com/package/stringify-object"><img src="https://img.shields.io/bundlephobia/minzip/stringify-object.svg" alt="minzipped size" height="18"></a> |
| Indentation | ✅ | 🟡 uncustomizable | ✅ | ✅ | ✅ |
| Auto line breaking | ✅ | ✅ | ❌ | ❌ | ❌ |
| Array elements grouping [1] | ✅ | ✅ | ❌ | ❌ | ❌ |
| Circular references | ✅ | ✅ | ✅ | ✅ | ✅
