Yes, that’s what the query is for. But since the query itself will be consumed via API, which I believe serves the results in json format, this should do.
It turns out that the query output is normalized for easy screen reading in Data Explorer web console only (both json and csv exports retain newlines), so this turns out to be a non-issue after all.