How to pretty print using System.Text.Json for unknown object
This works: using System.Text.Json; public static string JsonPrettify(this string json) { using var jDoc = JsonDocument.Parse(json); return JsonSerializer.Serialize(jDoc, new JsonSerializerOptions { WriteIndented = true }); }