Flask pretty-prints response generated by the `flask.json.jsonify` function. Avoiding this on a per request basis doesn't seem to be intended: There is a configuration variable for the whole application: `JSONIFY_PRETTYPRINT_REGULAR`. But setting that to `False` minifies every JSON responses. And, in general, I enjoyed the pretty printed output. So implementing `X-PrettyPrint` - which seems to be a quasi-standard - also sounded like a the wrong way because it means replacing the call to `jsonify` by a custom implementation. This short story has a happy end though: Flask does not pretty-print the response if it receives an AJAX request. So one can just send the appropriate header: ``` curl -H 'X-Requested-With: XMLHttpRequest' "https://exmaple.com/api/endpoint.json"; ```


Spoiler: My main point in this post is not given away by the title. But first things first: What are all those words? <a href="https://blag.nullteilerfrei.de/2017/10/29/python-post-json-data-containing-a-datetime-object-with-requests-to-flask/#more-4316" class="more-link">Would you like to know more?</a>