wasm-fmt/clang-format
wasm-fmt/clang-format has 30 GitHub stars and 5 forks. GitHot measured 0 stars in 24 hours, 0 in 7 days, and 0 in 15 days. Last checked 2026-11-15 14:32 UTC. Last push 2026-11-01.
Measured star growth
- in 24h
- 0
- in 7 days
- 0
- in 15 days
- 0
- in 1 month
- Collecting history
Net star changes over overlapping periods, not daily totals. Missing measurements are left blank. Stars measure attention, not software quality.
About
A WASM Based Clang Format | C / C++ / C# / Objective-C / Java / Protobuf
Web & AppsREADME.md
OriginalInstall
npm install @wasm-fmt/clang-format
npx jsr add @fmt/clang-format
Usage
CLI
This repository contains 3 executable files, namely clang-format, git-clang-format and clang-format-diff.
For more information, please refer to https://clang.llvm.org/docs/ClangFormat.html
Node.js / Deno / Bun / Bundler
import { format } from "@wasm-fmt/clang-format";
const source = `
#include <iostream>
using namespace std;
auto main() -> int{
std::cout << "Hello World!" << std::endl;
return 0;}
`;
// JSON representation of Clang-Format Style Options
const config = JSON.stringify({
BasedOnStyle: "Chromium",
IndentWidth: 4,
ColumnLimit: 80,
});
// or YAML representation of Clang-Format Style Options which is used in `.clang-format` file
const config2 = `---
BasedOnStyle: Chromium
IndentWidth: 4
ColumnLimit: 80
...
`;
// or the preset name
const config3 = "Chromium";
const formatted = format(source, "main.cc", config);
console.log(formatted);
The third argument of format is a Clang-Format Style Options, which can be one of the following:
- A preset: LLVM, GNU, Google, Chromium, Microsoft, Mozilla, WebKit.
- A YAML/JSON string representing the style options.
- the string content of a
.clang-formatfile.
See Clang-Format Style Options for more information.
Web
For web environments, you need to initialize WASM module manually:
import init, { format } from "@wasm-fmt/clang-format/web";
await init();
const source = `
#include <iostream>
using namespace std;
auto main() -> int{
std::cout << "Hello World!" << std::endl;
return 0;}
`;
const formatted = format(source, "main.cc", "Chromium");
console.log(formatted);
Vite
import init, { format } from "@wasm-fmt/clang-format/vite";
await init();
// ...
Entry Points
.- Auto-detects environment (Node.js uses node, Webpack uses bundler, default is ESM)./node- Node.js environment (no init required)./esm- ESM environments like Deno (no init required)./bundler- Bundlers like Webpack (no init required)./web- Web browsers (requires manual init)./vite- Vite bundler (requires manual init)
How does it work?
Clang-Format is a tool to format C/C++/Java/JavaScript/TypeScript/Objective-C/Protobuf/C# code.
This package is a WebAssembly build of Clang-Format, with a JavaScript wrapper.
Build from source
- Install LLVM and Clang (version 18 or later).
- Install CMake (version 3.27 or later).
- Install Ninja (version 1.11 or later).
- Install Emscripten (version 4.0.9).
- Clone this repository.
- Run scripts/build.sh.