
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
@monitext/nprint
Advanced tools
A lightweight library for text coloring, highlighting, and formatting in the console. Works with Node.js, Deno, Bun, and browsers.
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.
Install the library using your favorite package manager:
npm install @monitext/nprint
# or
pnpm add @monitext/nprint
# or
yarn add @monitext/nprint
You can use nprint in two ways:
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
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));
import { nprint } from "@monitext/nprint";
const myHex = nprint.hex("#05ffacff");
nprint.log(myHex.bold.underline("Custom styled text"));
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));
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"));
});
colsObject 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");
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);
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"
write(({ push, pretty }) => {
pretty.hr({
char: "=",
width: 50,
title: "Section Title",
align: "center",
titleColor: "blue",
hrColor: "gray",
});
});
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);
Add horizontal and vertical padding to text:
import { pad } from "@monitext/nprint";
const paddedText = pad("Hello, World!", { x: 2, y: 1 });
console.log(paddedText);
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);
write(({ push, cols, hex, bgHex }) => {
push(cols.bold(cols.underline(cols.red("Bold underlined red"))));
push(bgHex("#1a1a1a")(hex("#00ff00")("Green on dark background")));
});
const output = await writeAsync(async ({ push, cols }) => {
push(cols.blue("Loading data..."));
const data = await fetchData();
push(cols.green("Data loaded successfully!"));
});
The library is fully typed and provides excellent IntelliSense support:
import type { Theme } from "@monitext/nprint";
const theme: Theme = "githubDark"; // Autocomplete available
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.
Contributions are welcome! Please feel free to submit a Pull Request or open an issue.
FAQs
A lightweight library for text coloring, highlighting, and formatting in the console. Works with Node.js, Deno, Bun, and browsers.
We found that @monitext/nprint demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.