## Overview of JSON Formatting in JavaScript
When working with APIs or Node.js services, JSON payloads are frequently returned as compact strings without newlines or indentation. JavaScript provides a built-in method, `JSON.stringify()`, that accepts extra parameters for pretty printing.
Using JSON.stringify for Pretty Printing
The `JSON.stringify(value, replacer, space)` method accepts a third parameter `space` to specify indentation spacing:
// Pretty print with 2 spaces const formattedJson = JSON.stringify(userData, null, 2); console.log(formattedJson); ```
--- Need to quickly format raw API JSON strings right in your browser? Use our free online JSON Formatter tool below!