
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.
text-binary-converter
Advanced tools
Convert text to binary string and back (UTF-8). Zero dependencies.
Convert text to binary string and back (UTF-8). Supports full Unicode. Zero dependencies. TypeScript-first.
spaced, no-spaces, 8-bit-groupsbinaryToText ignores non-binary characters (spaces, pipes, newlines) automaticallyBuffer, no TextEncodernpm install text-binary-converter
# or
pnpm add text-binary-converter
# or
yarn add text-binary-converter
import { textToBinary, binaryToText } from 'text-binary-converter'
// Encode
textToBinary('Hi') // '01001000 01101001'
textToBinary('Hi', 'no-spaces') // '0100100001101001'
textToBinary('Hi', '8-bit-groups') // '01001000|01101001'
// Multi-byte Unicode works too
textToBinary('Привет') // valid UTF-8 binary
textToBinary('🌍') // 4-byte UTF-8 sequence
// Decode
binaryToText('01001000 01101001') // 'Hi'
binaryToText('0100100001101001') // 'Hi' — no-spaces format
binaryToText('01001000|01101001') // 'Hi' — separators are ignored
binaryToText(' 01001000 01101001\n') // 'Hi' — whitespace is ignored
// Round-trip
const bin = textToBinary('Hello, World! 🌍')
binaryToText(bin) // 'Hello, World! 🌍'
CommonJS (require) is also supported:
const { textToBinary, binaryToText } = require('text-binary-converter')
const bin = textToBinary('Hello')
console.log(bin) // '01001000 01100101 01101100 01101100 01101111'
console.log(binaryToText(bin)) // 'Hello'
textToBinary(text: string, format?: BinaryFormat): stringEncodes a string to its UTF-8 binary representation.
| Parameter | Type | Default | Description |
|---|---|---|---|
text | string | — | Input string (any Unicode is supported) |
format | BinaryFormat | 'spaced' | Output format (see table below) |
BinaryFormat options:
| Value | Example output | Description |
|---|---|---|
'spaced' | '01001000 01101001' | Bytes separated by spaces |
'no-spaces' | '0100100001101001' | Continuous bit string, no separators |
'8-bit-groups' | '01001000|01101001' | Bytes separated by | |
Returns '' for empty or non-string input.
binaryToText(binary: string): stringDecodes a binary string back to text, interpreting bytes as UTF-8.
| Detail | Behaviour |
|---|---|
| Non-binary chars | All characters except 0 and 1 are stripped before decoding |
| Formats accepted | spaced, no-spaces, 8-bit-groups, or any custom separator |
| Empty input | Returns '' |
| Invalid length | Throws Error if cleaned length is not a multiple of 8 |
| No binary digits | Throws Error if no 0/1 characters are found |
| Invalid UTF-8 | Throws Error if the byte sequence is not valid UTF-8 |
import { binaryToText } from 'text-binary-converter'
try {
binaryToText('010') // not a multiple of 8
} catch (e) {
console.error((e as Error).message)
// 'Binary string length (3) is not a multiple of 8'
}
try {
binaryToText(' ') // no binary digits
} catch (e) {
console.error((e as Error).message)
// 'No valid binary digits found'
}
git clone https://github.com/maksimgrushevsky/text-binary-converter.git
cd text-binary-converter
npm install
npm run build # compile to dist/
npm test # run tests once
npm run test:watch # run tests in watch mode
npm run typecheck # TypeScript type-check only
FAQs
Convert text to binary string and back (UTF-8). Zero dependencies.
We found that text-binary-converter 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.