yt-dlp-wasm runs yt-dlp in the browser and in Node.js through WebAssembly. It has no server of its own. The download logic runs on the user's device, so a web page or a Node.js program can fetch video without a backend that hosts yt-dlp.
It is a fork of yt-dlp. The extractors, format selection, output templates, and options are upstream's code.
Pyodide is CPython compiled to WebAssembly. It runs the unmodified yt-dlp Python code in a browser worker or in Node.js. Code that depends on something the platform lacks is replaced by a wasm-specific piece:
- Fetch request handler. Sends yt-dlp's HTTP requests with the host's
fetch, since Pyodide has no raw sockets. - ffmpeg bridge. Runs the
ffmpegandffprobecommands that yt-dlp issues on ffmpeg.wasm, a fork maintained alongside this project, instead of starting a subprocess. - YouTube JS challenge provider. Runs the EJS solver that YouTube needs on the host's own JavaScript engine.
- CORS proxy. A small proxy in
packages/cors-proxythat relays requests for browsers. It runs as a Cloudflare Worker or on a Linux machine at home. It also carries the headers browsers refuse to set, so cookies and redirects work as they do in Node.js.
The wasm code lives in new files and in small changes to upstream files that apply only when sys.platform == 'emscripten'. That keeps merges from upstream cheap.
The demo at https://yt-dlp-wasm.project516.dev runs yt-dlp in your browser and saves a video or its audio as a file. It needs a browser with JSPI (see below) and sends its requests through a rate limited proxy meant for personal use. The demo may not work from cloud servers, some VPNs, or automated browsers, because the proxy's domain challenges that traffic. If a site asks you to sign in, you can load a cookies.txt file in the demo's Cookies settings. Whoever runs the proxy can see the cookies, so load them only if you trust it. The file stays in memory until you close the page. Its source is in apps/demo.
@project516/yt-dlp-wasm on npm wraps yt-dlp on Pyodide in a small JavaScript API for browsers and Node.js.
pnpm add @project516/yt-dlp-wasmIn a browser, Pyodide runs in a module worker the library starts, so the page stays responsive.
import { createYtDlp } from '@project516/yt-dlp-wasm';
const ytdlp = await createYtDlp({ corsProxy: 'https://your-proxy.example/' });
const info = await ytdlp.extractInfo('https://example.com/video');
const [file] = await ytdlp.download(info, { format: 'bestaudio' }, {
onProgress: ({ status, downloadedBytes, totalBytes }) => console.log(status, downloadedBytes, totalBytes),
});
const url = URL.createObjectURL(new Blob([file.data], { type: file.mimeType }));
ytdlp.close();In Node.js, Pyodide runs in the same process and files are written to disk.
import { createYtDlp } from '@project516/yt-dlp-wasm';
const ytdlp = await createYtDlp();
const [file] = await ytdlp.download('https://example.com/video', { format: 'bestaudio' }, { outputDir: './downloads' });
console.log(file.path);
await ytdlp.close();The package also installs a yt-dlp-wasm command that takes the arguments of yt-dlp.
createYtDlp(options) takes these, all optional:
corsProxy,corsProxyKey: URL and access key of a CORS proxy.cookies: the text of a Netscapecookies.txtfile.extractInfoanddownloaduse it ascookiefileunless their options set one.runadds--cookiesunless the arguments have--cookiesor--no-cookies. The file stays in Pyodide's memory and is never written to disk. In a browser the cookies go through your CORS proxy, and whoever runs it can see them, so use cookies only with a proxy you trust.pyodideIndexURL: where Pyodide loads from. The default is jsDelivr in browsers and the installedpyodidepackage in Node.js.ffmpegCoreURL: where the ffmpeg.wasm core loads from in browsers. The default is@project516/ffmpeg-wasm-core-jspion jsDelivr. The directory must hold itsffmpeg-core.jsandffmpeg-core.wasmfromdist/esm.wheelURL: the yt-dlp wheel in browsers. The default is the package'sdist/folder next to the module, so a bundler has to serve that folder or you pass this.env: environment variables for Python.onLog(line, stream): receives each line yt-dlp writes to stdout or stderr.
The returned object has these methods:
run(args)takes the arguments ofyt-dlpand resolves with the exit code.extractInfo(url, options)resolves with the info dict.download(urlOrInfo, options, { onProgress, outputDir })downloads. Pass the info dict fromextractInfoso the page is not extracted twice.close()waits for running calls, andterminate()stops at once.
The options are the keys of yt-dlp's Python YoutubeDL options, as JSON. Calls on one instance run one at a time.
A browser download resolves with { name, data, mimeType } for each file, with data a Uint8Array moved out of the worker without a copy, and frees the file from memory. A Node.js download resolves with { name, path, size, mimeType }. Types are in src/index.d.ts.
yt-dlp makes blocking network and ffmpeg calls. Pyodide waits on them with JavaScript Promise Integration (JSPI), so the runtime must have it: Chrome 137, Firefox 153, Safari 27 or Node.js 25. Without JSPI, createYtDlp rejects and names those versions.
A browser blocks a request to another origin unless that origin allows it, and most sites do not. Set corsProxy to your own deployment of packages/cors-proxy. Its README shows how to run one on Cloudflare's free plan, or on an always-on Linux machine at home with about 512 MB of RAM. YouTube often refuses requests from Cloudflare Workers, because they share datacenter IP addresses, so use a proxy at home for YouTube. Node.js sends requests directly and needs no proxy.
Where the platform cannot do what yt-dlp does, yt-dlp-wasm behaves differently:
- In the browser, requests go through the CORS proxy, so sites see the proxy's IP address. Some sites challenge datacenter addresses.
- There is no impersonation, because
curl_cffiis not available. - There is no proxy support, no client certificate support, and no websocket support.
- There are no threads, so fragments that yt-dlp downloads concurrently are downloaded one at a time.
- ffmpeg can't open network inputs, so the ffmpeg downloader is unavailable. yt-dlp's own HLS and DASH downloaders are used instead.
- In the browser, downloads live in memory, and
--cookies-from-browsercan't read the browser's cookies.
The options are the same as yt-dlp's. For the full reference see the upstream README. Options that depend on a feature listed above, such as --proxy or --impersonate, do not work here.
This is a pnpm monorepo. The Python package stays at the root as in upstream. The JavaScript lives in packages/yt-dlp-wasm (the library, CLI and Pyodide test harness), packages/cors-proxy, and the demo site in apps/demo.
pnpm install
pnpm --filter @project516/yt-dlp-wasm build
pnpm --filter @project516/yt-dlp-wasm testThe test harness runs yt-dlp's own test suite inside Pyodide. It needs Node.js 25 or later.
cd packages/yt-dlp-wasm
node test-harness/run-tests.mjs core
node test-harness/run-tests.mjs test/test_utils.py --pytest-args='-x'The same suite also runs on native CPython with python -m devscripts.run_tests core. Both must pass. See CONTRIBUTING.md.
This fork tracks the stable releases of yt-dlp/yt-dlp. A daily workflow merges each new release tag and publishes a new minor version of the npm package, and the release notes name the yt-dlp version it is based on. Bugs that also happen with regular yt-dlp, such as a broken site or a missing extractor, belong in the upstream issue tracker. Bugs that only happen under WebAssembly belong in the issues of this repository.
Upstream's release builds, installation methods, and update channels do not apply to this fork. Upstream's Changelog is kept as history.
See CONTRIBUTING.md. The maintainer is listed in Maintainers.md.
The fork's own changes and additions are licensed under AGPL-3.0-or-later. Code that comes from yt-dlp keeps upstream's Unlicense. The Unlicense is compatible with the AGPL, so the combined work is distributed under the AGPL.
Releases of upstream yt-dlp bundle third-party code under other licenses. See THIRD_PARTY_LICENSES.txt.
yt-dlp-wasm is built on yt-dlp, itself a fork of youtube-dl. Thanks to the people credited in CONTRIBUTORS for the code it runs.