npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@codewaveds/beautify-json-log

v1.0.1

Published

Beautify JSON log for React

Readme

🎨 beautify-json-log

Uma biblioteca para visualizar e inspecionar valores JavaScript/JSON com realce de sintaxe por tipo, tanto no terminal (Node.js) quanto em aplicações React.


📦 Instalação

npm i -D @codewaveds/beautify-json-log
# ou
yarn add -D @codewaveds/beautify-json-log

Terminal

import { BeautifyJsonLog } from '@codewaveds/beautify-json-log';

BeautifyJsonLog('Meu objeto', {
  nome: 'Alice',
  idade: 30,
  ativo: true,
  score: null,
  tags: ['admin', 'user'],
  criado: new Date(),
  meta: new Map([['chave', 1]]),
  ids: new Set([1, 2, 3]),
});

Exibe no terminal uma visualização colorida e formatada, com suporte completo a:

  • 🟩 Chaves em verde
  • 🔠 Strings em azul
  • 🔢 Números em amarelo
  • 🔘 Booleanos em magenta
  • Null / Error em vermelho
  • 🔵 Date / Map / Set em ciano
  • undefined em cinza
  • 🔁 Referências circulares detectadas e exibidas como [Circular]
  • 📦 BigInt com sufixo n

Opções

BeautifyJsonLog('título', valor, {
  indent: 4,           // espaços de indentação (padrão: 2)
  theme: meuTema,      // AnsiTheme customizado
  transport: console.error, // onde enviar a saída (padrão: console.log)
  plugins: [minhaTransformação], // transforma a árvore antes de renderizar
});

React

import { JsonViewer } from '@codewaveds/beautify-json-log';

<JsonViewer title="Resposta da API" value={data} />

Props

| Prop | Tipo | Padrão | Descrição | |---|---|---|---| | value | unknown | — | Valor a exibir | | title | string | — | Título opcional acima do viewer | | theme | CssTheme | tema padrão (VS Code dark) | Cores CSS para cada tipo | | indent | number | 16 | Indentação em pixels | | plugins | Plugin[] | [] | Transforma a árvore antes de renderizar | | style | CSSProperties | — | Estilo do container |


Plugins

Plugins são funções que recebem o nó raiz da árvore (RenderNode) e retornam um nó transformado. Útil para ocultar campos sensíveis, mascarar valores, etc.

import { BeautifyJsonLog, Plugin } from '@codewaveds/beautify-json-log';

const redact: Plugin = node => {
  if (node.kind !== 'object') return node;
  return {
    ...node,
    entries: node.entries.map(e =>
      e.key === 'senha'
        ? { key: e.key, value: { kind: 'primitive', valueType: 'string', raw: '"[REDACTED]"' } }
        : e
    ),
  };
};

BeautifyJsonLog('Usuário', usuario, { plugins: [redact] });

O mesmo plugin funciona tanto no terminal quanto no <JsonViewer>.


Temas

Terminal (AnsiTheme)

import { BeautifyJsonLog, AnsiTheme } from '@codewaveds/beautify-json-log';

const meuTema: AnsiTheme = {
  key: s => `\x1b[35m${s}\x1b[0m`,      // magenta
  string: s => `\x1b[33m${s}\x1b[0m`,   // amarelo
  number: s => `\x1b[36m${s}\x1b[0m`,   // ciano
  boolean: s => `\x1b[32m${s}\x1b[0m`,  // verde
  null: s => `\x1b[31m${s}\x1b[0m`,     // vermelho
  undefined: s => s,
  bigint: s => `\x1b[36m${s}\x1b[0m`,
  date: s => `\x1b[34m${s}\x1b[0m`,
  error: s => `\x1b[31m${s}\x1b[0m`,
  bracket: s => s,
  punctuation: s => s,
  circular: s => `\x1b[31m${s}\x1b[0m`,
  special: s => `\x1b[34m${s}\x1b[0m`,
};

BeautifyJsonLog('Log', dados, { theme: meuTema });

React (CssTheme)

import { JsonViewer, CssTheme } from '@codewaveds/beautify-json-log';

const meuTema: CssTheme = {
  key: '#c586c0',
  string: '#ce9178',
  number: '#b5cea8',
  boolean: '#569cd6',
  null: '#f44747',
  undefined: '#808080',
  bigint: '#b5cea8',
  date: '#4fc1ff',
  error: '#f44747',
  bracket: '#d4d4d4',
  punctuation: '#d4d4d4',
  circular: '#f44747',
  special: '#4fc1ff',
};

<JsonViewer value={dados} theme={meuTema} />

API

// Renderização no terminal
BeautifyJsonLog(title: string, value: unknown, options?: LoggerOptions): void
formatTree(node: RenderNode, options?: FormatOptions): string
buildTree(value: unknown): RenderNode

// Componente React
<JsonViewer value={unknown} ...props />

// Tipos
type Plugin = (node: RenderNode) => RenderNode
type Transport = (output: string) => void
type AnsiTheme = Record<ThemeKey, (s: string) => string>
type CssTheme = Record<ThemeKey, string>