Spring Boot — “String value length exceeds maximum allowed” when uploading large file in JSON
04:46 20 Nov 2025

I'm building a Spring Boot application where I'm trying to upload files or large content through a REST endpoint. The request is being rejected by Spring Boot with this warning:

HttpMessageNotReadableException: JSON parse error:
String value length (20048537) exceeds the maximum allowed
(20000000, from StreamReadConstraints.getMaxStringLength())

It looks like Jackson is blocking the request because the JSON string is too large. I'm not trying to catch this exception — I just want to understand:

Why this limit exists

Whether I'm uploading the file in the wrong way

What the correct approach is for handling large file uploads in Spring Boot

Has anyone dealt with the StreamReadConstraints max string length issue? What is the recommended way to upload large files without hitting this JSON size restriction?

Thanks!

java spring-boot