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

@monitext/nprint

v0.3.0

Published

A lightweight library for text coloring, highlighting, and formatting in the console. Works with Node.js, Deno, Bun, and browsers.

Readme

@monitext/nprint

Introduction

Nprint is a cross-platform console logging and styling utility that works seamlessly in Node.js, Deno, Bun, and browsers (Yes — even browser consoles support full color!). It provides a rich API for color manipulation, syntax highlighting, and terminal utilities, making it an essential tool for developers who want to enhance their console output.

Features

  • 🎨 Cross-platform color support - Works in Node.js, Bun, Deno, and browsers.
  • 🖥️ Auto-runtime detection - Automatically detects the environment and applies appropriate styling.
  • 🌈 Rich color API - Support for named colors, hex colors, and background colors.
  • 💻 Syntax highlighting - Powered by highlight.js with multiple themes.
  • 📏 Terminal utilities - Terminal width detection and horizontal rule generation.
  • 🔄 Flexible rendering - Support for both synchronous and asynchronous operations.
  • 🎯 TypeScript support - Fully typed with comprehensive TypeScript definitions.

Installation

Install the library using your favorite package manager:

npm install @monitext/nprint
# or
pnpm add @monitext/nprint
# or
yarn add @monitext/nprint

Quick Start

Basic Color Usage

You can use nprint in two ways:

Using the Wrapper

import { nprint } from "@monitext/nprint";

const output = nprint.write(({ push }) => {
  const { cols } = nprint;
  push(cols.red("Error: Something went wrong!"));
  push(cols.green("Success: Operation completed"));
  push(cols.blue.bold("Bold blue text"));
});

nprint.log(output); // Wrapper around console.log

Using the Render Function

import { write, render, cols } from "@monitext/nprint";

const output = write(({ push }) => {
  push(cols.red("Error: Something went wrong!"));
  push(cols.green("Success: Operation completed"));
  push(cols.blue.bold("Bold blue text"));
});

console.log(...render(output));

Hex Colors

import { nprint } from "@monitext/nprint";

const myHex = nprint.hex("#05ffacff");

nprint.log(myHex.bold.underline("Custom styled text"));

Syntax Highlighting

import { code, registerLang, render } from "@monitext/nprint";
import javascript from "highlight.js/lib/languages/javascript";

// Register the language first
registerLang("javascript", javascript);

const output = code({
  lang: "javascript",
  content: `
function greet(name) {
  console.log(\`Hello, \${name}!\`);
}
greet("World");
  `,
  theme: "githubDark", // or "monokai", "vs", "far"
});

console.log(...render(output));

API Reference

Core Functions

write(fn)

The main function for creating styled output. Automatically detects whether the function is synchronous or asynchronous.

const output = write(({ push, cols, hex, bgHex, code, pretty }) => {
  push("Regular text");
  push(cols.red("Red text"));
  push(hex("#FF0000")("Hex red text"));
});

writeSync(fn)

Synchronous version of the write function.

const output = writeSync(({ push, cols }) => {
  push(cols.green("Synchronous green text"));
});

writeAsync(fn)

Asynchronous version of the write function.

const output = await writeAsync(async ({ push, cols }) => {
  await someAsyncOperation();
  push(cols.blue("Asynchronous blue text"));
});

Color Functions

cols

Object containing all available color functions based on chalk styling:

cols.red("Red text");
cols.green.bold("Bold green text");
cols.bgBlue("Text with blue background");

hex(color)

Apply custom hex colors to text:

hex("#FF5733")("Orange text");

bgHex(color)

Apply custom hex background colors:

bgHex("#333333")("Text with dark background");

Syntax Highlighting

code(options)

Render syntax-highlighted code:

const output = code({
  lang: "typescript",
  content: "const x = 42;",
  theme: "githubDark",
});

registerLang(name, descriptor)

Register a new language for syntax highlighting:

import { registerLang } from "@monitext/nprint";
import python from "highlight.js/lib/languages/python";

registerLang("python", python);

Utility Functions

getTerminalWidth(defaultWidth?)

Get the current terminal width:

const width = getTerminalWidth(); // Auto-detect

detectRuntime()

Detect the current JavaScript runtime:

const runtime = detectRuntime();
// Returns: "node" | "bun" | "deno" | "browser" | "unknown"

Horizontal Rules

write(({ push, pretty }) => {
  pretty.hr({
    char: "=",
    width: 50,
    title: "Section Title",
    align: "center",
    titleColor: "blue",
    hrColor: "gray",
  });
});

Text Effects

Box

Create a box around text with customizable colors and rounded corners:

import { box } from "@monitext/nprint";

const boxedText = box("Hello, World!", { color: "blue", rounded: true });
console.log(boxedText);

Pad

Add horizontal and vertical padding to text:

import { pad } from "@monitext/nprint";

const paddedText = pad("Hello, World!", { x: 2, y: 1 });
console.log(paddedText);

Vertical Bar

Add a vertical bar to the left of text with customizable styling:

import { vbar } from "@monitext/nprint";

const barredText = vbar("Hello, World!", { color: "gray", bold: true, pad: 2 });
console.log(barredText);

Advanced Usage

Custom Color Combinations

write(({ push, cols, hex, bgHex }) => {
  push(cols.bold(cols.underline(cols.red("Bold underlined red"))));
  push(bgHex("#1a1a1a")(hex("#00ff00")("Green on dark background")));
});

Async Operations

const output = await writeAsync(async ({ push, cols }) => {
  push(cols.blue("Loading data..."));
  const data = await fetchData();
  push(cols.green("Data loaded successfully!"));
});

TypeScript Support

The library is fully typed and provides excellent IntelliSense support:

import type { Theme } from "@monitext/nprint";

const theme: Theme = "githubDark"; // Autocomplete available

Environment Support

  • Node.js - Full ANSI color support
  • Bun - Full ANSI color support
  • Deno - Full ANSI color support
  • Browser - Console styling with CSS
  • TypeScript - Complete type definitions

Why @monitext/nprint?

Unlike other libraries like Chalk or Colorette, @monitext/nprint unifies terminal and browser styling, includes syntax highlighting out of the box, and is built around a pseudo-rendering system that makes it easy to format strings, code, and pretty outputs in one place.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request or open an issue.