Yes, you can change this using the config attribute:
app = Flask(__name__) app.config['JSON_SORT_KEYS'] = False
However, note that this is explicitly stated in the documentation:
By default, Flask will serialize JSON objects so that the keys are ordered. This is done in order to ensure independence from the hash seed of the dictionary, the return value will correspond not to garbage of external HTTP caches. You can override the default behavior by changing this variable. This is not recommended, but can give you increased performance at the cost of caching.
source share