Skip to content

tersify

One readable line for any value — built for error messages, logs, and assertions.

tersify turns any JavaScript value — a primitive, an object, an array, a class instance, a function — into a short string you can put in an error message without drowning the reader in it. JSON.stringify refuses functions, loses classes, and throws on cycles. util.inspect is Node-only and formats for a terminal. tersify is neither: it produces one compact, length-bounded string that works the same in Node and in the browser.

  • Introduction — the problem it solves and when to reach for it.
  • Installation — install, import, and the Node/browser split.
  • OptionsmaxLength, indent, and raw.
  • Reference — every export, one page each.