Structured output size is big because of formatting

Hi, started using structured json output with gemini 2.5 flash but it returns well-formatted json meaning with new lines and indents. I see there is some benefit in that but it increases size of output which increases both time and costs. On the other hand openai models return structured output in a form of json without spaces and new line chars. Is it possible to do the same for gemini models? Are there plans for that? Do you have some workarounds? The lack of that minification of json defeats the purpose of switching from openai models to gemini for my use-case as I generate jsons most of the time.

@Kamil_Zytka ,

welcome to the forum.

Thanks for the feedback ,
one workaround i would suggest is , use json lib in python.
json.loads() will load the json from the string and you want the string format you can get it from json.dumps() from the json.
this will give you the string without the spaces and newlines

Hi @Akhilesh_Kambhampati , I don’t have problems using generated json output. The problem is that it is generated with those extra characters. If it was without those characters, it would save sometimes half of tokens and time. Would be great if gemini generated minified json without any spaces or new line characters.

Hi, any updates on the issue?