Full ESNext & TypeScript Syntax Support
Handles async/await, arrow functions, object destructuring, optional chaining, nullish coalescing, and modern syntax patterns seamlessly.
Free online JavaScript Formatter and Beautifier. Clean and indent JavaScript and TypeScript snippets, format objects and functions, minify code for production, with client-side privacy.
Format, clean up scopes, and minify JS and TS scripts
async function fetchWithRetry(url, options= {
}
, maxRetries=3) {
let delay=500;
for(let attempt=1; attempt<=maxRetries; attempt++) {
try {
const response=await fetch(url, {
...options, headers: {
'Content-Type':'application/json', ...options.headers
}
})
;
if(!response.ok) {
throw new Error(`Request failed with status ${response.status}`);
}
return await response.json();
}
catch(error) {
if(attempt===maxRetries) {
console.error('All retry attempts exhausted:', error);
throw error;
}
console.warn(`Attempt ${attempt} failed, retrying in ${delay}ms...`);
await new Promise((resolve)=>setTimeout(resolve, delay));
delay*=2;
}
}
}A developer unpacks a compacted JavaScript helper function from a bundle to debug asynchronous data fetching and error handling.
| Minified Input | async function fetchData(url,retries=3){for(let i=0;i<retries;i++){try{const res=await fetch(url);if(!res.ok)throw new Error(`HTTP ${res.status}`);return await res.json();}catch(err){if(i===retries-1)throw err;await new Promise(r=>setTimeout(r,1000*2**i));}}} |
| Formatted Output | async function fetchData(url, retries = 3) { for (let i = 0; i < retries; i++) { try { const res = await fetch(url); if (!res.ok) { throw new Error(`HTTP ${res.status}`); } return await res.json(); } catch (err) { if (i === retries - 1) { throw err; } await new Promise((r) => setTimeout(r, 1000 * 2 ** i)); } } } |
💡 The reformatted code clearly highlights loop retry logic, exponential backoff, and exception boundaries for safe code review.
Paste your unformatted, minified, or messy JavaScript or TypeScript code into the input editor, or choose from realistic code presets.
Choose your preferred indentation size (2 spaces, 4 spaces, or Tab) and formatting preferences.
Click Beautify to neatly format functions, nested blocks, arrays, and objects, or click Minify to compact code into a single line.
Copy the formatted script to your clipboard or download it as a .js file.
Handles async/await, arrow functions, object destructuring, optional chaining, nullish coalescing, and modern syntax patterns seamlessly.
Tracks nested scopes across curly braces, parentheses, and brackets for consistent, readable code structure.
Quickly strip whitespace and comments for quick one-line scripts or bookmarklet distribution.
Yes. It cleanly formats modern ECMAScript, TypeScript syntax, async functions, arrow functions, and nested object literals.
No. All JavaScript formatting and minification take place locally inside your browser sandbox. None of your source code ever leaves your machine.
No. The minifier carefully preserves quoted strings (single, double, and template literals) as well as regular expression literals.
Developer Tools
Format, beautify, and minify CSS code online. Clean up messy stylesheets, indent rules, sort CSS properties alphabetically, and compress stylesheet files client-side.
Format, beautify, and minify HTML, XML, and SVG markup with clean indentation, comment stripping, and real-time live preview.
Format, beautify, validate, and minify JSON data online with instant syntax error highlighting and tree inspection.
Convert cURL command lines into production-ready code snippets for JavaScript Fetch, Axios, Python Requests, Go net/http, PHP cURL, and Node.js.
Generate secure, cryptographically random Version 4 (v4) and time-ordered Version 7 (v7) UUIDs and GUIDs with custom formatting, bulk batch generation, and live inspection.
Explore, navigate, and inspect complex JSON payloads with an interactive collapsible tree viewer, type badges, node search, and JSON path copying.