What JSON is, and the errors that break it
JSON (JavaScript Object Notation) is the standard text format for exchanging data between systems, made of key-value pairs in objects { } and ordered lists in arrays [ ]. It is human-readable and language-independent, which is why almost every web API returns it. Formatting (or "prettifying") it adds the indentation and line breaks that make a dense one-line response easy to read; minifying does the reverse to save space.
The mistakes that cause "invalid JSON". The strict rules trip people up: every key must be in double quotes (not single, and not unquoted), there must be no trailing comma after the last item, and comments are not allowed. Values can only be strings, numbers, booleans, null, objects or arrays, so a stray function or a date object will fail. The formatter above validates as it goes and points to where the structure breaks.
Reading a big response. When an API returns a wall of JSON, formatting it reveals the shape: which fields are nested, which are arrays you can loop over, and where the value you need actually sits. That structure is what you map your code to, so a clean, indented view is the first step in working with any unfamiliar API.