Browser integration

Classic script

The hosted /api.js bundle exposes the global DecodeBox object. Use it with a classic script tag and await DecodeBox.ready before calling the SDK.

<script src="https://decodebox.owasp.org/api.js"></script>
<script type="module">
  await DecodeBox.ready;
  console.log(await DecodeBox.executeOperation("to-base64", "Hello")); // SGVsbG8=
</script>

The extensionless /api alias serves the same classic bundle and is used by the existing ZAP add-on. SDK calls run in the application that loads the script.

ES module

Import the SDK in an external module or a <script type="module"> block.

import DecodeBox from "https://decodebox.owasp.org/sdk/decodebox.mjs";

await DecodeBox.ready;
console.log(await DecodeBox.executeOperation("from-base64", "SGVsbG8=")); // Hello

For cross-origin module loading, the server must respond with a JavaScript MIME type and allow the page's origin through CORS. If your site sets a Content Security Policy, permit the SDK's script origin and load your own initialization code according to that policy. Use HTTPS or localhost for operations that require Web Crypto.

Local development and offline usage

For offline use or self-hosting, keep a verified copy of the classic bundle alongside your page. You can also download a verified milestone bundle. To build from source now, install Node.js 24 and run the following commands.

git clone https://github.com/OWASP/DecodeBox.git
cd DecodeBox
npm ci
npm run build:sdk
npm run check:sdk-dist

For a published SDK release, check out its Git tag before installing dependencies. The build creates dist/api.js and the dist/sdk/ aliases. Save this as dist/example.html and open it from disk, or copy both example.html and api.js to your own static site.

<meta charset="utf-8">
<script src="./api.js"></script>
<script>
  DecodeBox.ready.then(async () => {
    const result = await DecodeBox.executeOperation("from-base64", "SGVsbG8=");
    console.log(result); // Hello
  });
</script>

The browser can open these two files and print Hello with the network disconnected. To update, obtain or build the new release, verify its digest, then replace the local bundle and update any integrity pin your application uses.