Fetch any webpage and produce a fully self-contained HTML file with all external resources — images, stylesheets, scripts, and SVGs — inlined directly into the document.
Open Table of contents
pnpm install @stephansama/single-file# outputs to single-file.html by default
npx @stephansama/single-file <url>
# custom output path
npx @stephansama/single-file <url> --output my-page.html
npx @stephansama/single-file <url> -o my-page.html
# verbose logging
npx @stephansama/single-file <url> --verbose
npx @stephansama/single-file <url> -v| Flag | Alias | Default | Description |
|---|---|---|---|
--output |
-o |
single-file.html |
Output path for the HTML file |
--verbose |
-v |
false |
Enable verbose output |
import * as singleFile from "@stephansama/single-file";
export async function useAPI() {
const file = await singleFile.convertPageToSingleFile(
"https://blog.stephansama.info",
);
console.info(file);
}