Character limit of a javascript string variable Code Answer

Hello Developer, Hope you guys are doing great. Today at Tutorial Guruji Official website, we are sharing the answer of Character limit of a javascript string variable without wasting too much if your time.

The question is published on by Tutorial Guruji team.

Can JavaScript string store 100K characters?
I’ve written a script where a string from PHP is passed to a variable in JavaScript. It works fine when it is cut short to almost ten thousand characters but breaks the script when attempting to pass the entire string whose length is a bit greater than 100K. No errors could be found though. Is there any solution for this as to any way of increasing character limit of JavaScript variable? I’m just a beginner. Would appreciate is some one could find a solution for this.


There is no theorical limit to JS or PHP on the size of their strings.

I think there are a few possible situations.

Firstly, check that you are not sending your string via HTTP GET. There is a maximum size for GET and i think its dependent on your web server.

Secondly, if you do use POST, check in php.ini for post_max_size and see if it is smaller than the string size you are sending to it as well as your .htacccess file to see if php_value post_max_size is not too small.

Thirdly, check that in php.ini that your memory_limit does not restrict the size of memory that your script can use.

hope this helps.

We are here to answer your question about Character limit of a javascript string variable - If you find the proper solution, please don't forgot to share this with your team members.

Related Posts

Tutorial Guruji