utf-8-validate

Native addon that validates UTF-8 buffers at C++ speed, with a pure-JS fallback for unsupported platforms.

Library
npm
v6.0.6
128stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
60/100Good
Development Activity60
Maintenance36
Community72
Maturity60
Momentum12

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
54/100Fair
Architecture72
Code Quality62
Innovation38
Learning Curve45

utf-8-validate is a small native Node.js addon that checks whether a Buffer contains valid UTF-8-encoded text. It exports a single function, isValidUTF8(buffer), backed by a C++ implementation (the vendored is_utf8 library) compiled via node-gyp-build, with prebuilt binaries shipped for common platforms so consumers avoid a local compile step. When no prebuilt binary is available for the current platform or architecture, it transparently falls back to a pure-JavaScript implementation so the package remains usable everywhere Node.js runs.

The library exists primarily to give the ws WebSocket library, and other real-time or binary-protocol code, a fast way to validate the UTF-8 payload of text frames per the WebSocket protocol (RFC 6455), which requires closing a connection when a text frame contains invalid UTF-8. Its narrow, single-purpose API and native-with-fallback design make it a common optional dependency wherever raw buffer-to-UTF-8 validation needs to be fast and reliable.

What You Get

  • A single exported function isValidUTF8(buffer) with a boolean return value, no configuration or options to learn
  • A native C++ addon (built on the vendored is_utf8 library) for maximum validation speed, loaded via node-gyp-build
  • Prebuilt binaries for macOS, Linux, and Windows across x64/arm64/x86 and multiple Node.js versions, so installs skip local compilation
  • A pure-JavaScript fallback (fallback.js) that activates automatically when no matching prebuilt binary exists for the host platform

Common Use Cases

  • Validating the payload of WebSocket text frames before delivering them to application code, as required by RFC 6455
  • Used as an optional dependency of the ws library to accelerate UTF-8 checks when the native binding is available
  • Validating buffers of unknown or external origin (file uploads, network payloads) before treating them as UTF-8 text

Under The Hood

Architecture utf-8-validate is architected as a thin two-layer module: index.js attempts to load a native addon via node-gyp-build, and transparently falls back to a pure-JavaScript implementation in fallback.js if no matching prebuilt binary is found for the host platform or Node version. The native path (src/validation.cc) is a minimal N-API binding that marshals a single Buffer argument into the externally vendored is_utf8 C++ library (deps/is_utf8), returning a boolean. There is no internal layering beyond this native/fallback boundary; the entire surface area is one exported function, so there is little to break beyond the binding itself failing to load, which is exactly the case the fallback exists to handle.

Tech Stack The package targets Node.js >=6.14.2 and builds via node-gyp/binding.gyp against the N-API ABI (NAPI_VERSION 1) for cross-version binary compatibility, vendoring the is_utf8 C++ library as its actual validation implementation. Runtime dependencies are limited to node-gyp-build for locating the correct prebuilt binary at install time; devDependencies (prebuildify, prebuildify-cross, node-gyp, mocha) exist purely to produce and test those binaries. GitHub Actions CI builds and tests across a matrix of macOS/Linux/Windows, x64/arm64/x86, and multiple Node.js versions, then a separate release job runs prebuildify (including a musl/Alpine cross-build) and publishes tarballed prebuilt binaries to GitHub Releases on tag pushes.

Code Quality Testing uses mocha with a single parameterized test suite (test/test.js) that runs the same assertions against both the native binding and the fallback implementation, checking empty buffers, valid multi-byte UTF-8 (including autobahn test-suite fixtures), and known-invalid sequences such as overlong encodings and lone surrogates. CI runs this suite across every OS/arch/Node-version combination in the build matrix, giving strong confidence the native and fallback paths stay behaviorally identical. There is no linter or formatter configuration in the repository, and the codebase is plain JavaScript with no shipped type definitions, so there is no static type safety; error handling is minimal by design since the function performs no external I/O and needs none.

API Design The public API is about as minimal as a Node package can be: a single default export, isValidUTF8(buffer), taking one Buffer argument and returning a boolean, with no options object, no configuration, and no state. This makes onboarding trivial, the README’s one code sample is effectively the entire learning curve, and the optionalDependencies convention plus the automatic native/fallback swap means consumers get the performance benefit without needing any awareness of the native-binding mechanics. The README explicitly documents that the argument is not validated and correctness is the caller’s responsibility, trading input safety for raw throughput, an appropriate tradeoff for its intended use inside performance-sensitive libraries like ws.

Used by 8 apps in this directory

Rust
67%
MIT

Bun

Developer Tools

95,895

An all-in-one JavaScript and TypeScript toolkit — one Rust-and-JavaScriptCore binary that replaces Node.js, npm, a bundler, and a test runner with faster equivalents.

View details
92
Repo Health
91
Technical
64
Dependency
Built with
Rust67%
C++19%
Updated yesterday
TypeScript
99%
Apache 2.0

Colanode

Knowledge Management · Team Chat · Collaboration

5,097

Local-first, self-hosted workspace that combines real-time chat, Notion-style pages, and structured databases — all synced via CRDTs so you work offline without losing a keystroke.

View details
47
Repo Health
73
Technical
70
Dependency
Built with
TypeScript99%
Updated 5 months ago
TypeScript
61%
EPL-2.0

Huly Platform

Project Management · Team Chat · Collaboration

27,586

Open-source all-in-one workspace that replaces Linear, Jira, Slack, and Notion for product and engineering teams.

View details
89
Repo Health
86
Technical
62
Dependency
Built with
TypeScript61%
Svelte34%
Updated 1 weeks ago
JavaScript
63%
AGPL 3.0

overleaf

Collaboration · Productivity

18,090

Open-source, real-time collaborative LaTeX editor with sandboxed compilation and full TeXLive support for self-hosted academic and research teams.

View details
82
Repo Health
80
Technical
62
Dependency
Built with
JavaScript63%
TypeScript29%
Updated 1 months ago
TypeScript
79%
AGPL 3.0

Postiz

Social Media · Automation

35,528

The agentic social media scheduler — AI-powered content creation, 33-platform posting, and team workflows, all self-hosted.

View details
91
Repo Health
70
Technical
63
Dependency
Built with
TypeScript79%
JavaScript12%
Updated 3 days ago
TypeScript
92%
Apache 2.0

superset

AI Code Assistants · AI Development

13,825

Orchestrate an army of AI coding agents—Claude Code, Codex, Gemini CLI, and more—running simultaneously in isolated git worktrees from a single Electron desktop app.

View details
85
Repo Health
80
Technical
67
Dependency
Built with
TypeScript92%
Updated today
JavaScript
55%
AGPL 3.0

ToolJet

Low Code Platforms · No Code Platforms · AI Agents

40,857

Open-source AI-native platform to build and deploy internal tools, workflows, and AI agents with a visual drag-and-drop builder and 80+ data source integrations.

View details
94
Repo Health
81
Technical
63
Dependency
Built with
JavaScript55%
TypeScript38%
Updated today
TypeScript
85%
Other

Webiny JS

Ecommerce · Blogging · CMS

8,032

Open-source, self-hosted CMS on AWS serverless — a TypeScript framework you extend with code, not a product you configure through a UI.

View details
90
Repo Health
86
Technical
62
Dependency
Built with
TypeScript85%
JavaScript14%
Updated yesterday

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search