Global / Window

atob

Decodes a string of data which has been encoded using Base64 encoding

Syntax

JavaScript
atob(encodedData)

Parameters

ParameterTypeDescription
encodedDatastringA binary string containing base64-encoded data

Return Value

A string containing decoded data from encodedData

Examples

Basic Usage
const decoded = atob('SGVsbG8gV29ybGQ=');
console.log(decoded); // 'Hello World'
Practical Example
const base64 = 'eyJuYW1lIjoiQWxpY2UifQ==';
const json = atob(base64);
console.log(JSON.parse(json)); // { name: 'Alice' }
Advanced Usage
function decodeJwtPayload(token: string) {
  const payload = token.split('.')[1];
  return JSON.parse(atob(payload));
}

Understanding atob

The atob method in JavaScript decodes a string of data which has been encoded using Base64 encoding. It belongs to the window object and is one of the most widely used methods for working with window values in modern JavaScript and TypeScript applications.

The method signature is atob(encodedData). It accepts 1 parameter: encodedData. When called, it returns a string containing decoded data from encodeddata. Understanding when and how to use atob() helps you write more expressive, readable code.

Common use cases for atob include data transformation, input validation, API response processing, and building reusable utility functions. It works well alongside related methods like window-btoa, enabling you to chain operations together for complex data manipulation pipelines.

Browser support for atob is excellent across all modern browsers including Chrome, Firefox, Safari, and Edge. It is also fully supported in Node.js and Deno. For older environments, transpilation with Babel or a polyfill may be needed.

Browser Compatibility

Supported in all modern browsers (Chrome, Firefox, Safari, Edge) and Node.js. Part of the ECMAScript standard.

Related Methods

More Global / Window Methods

Other methods in the Global / Window object

Related Tools

More Global / Window Methods

Explore JavaScript Methods

Browse our complete reference of 410 JavaScript methods with syntax, examples, and explanations.