Question: I am high school math teacher who is teaching myself programming. My apologies in advance if I don't phrase some of this correctly. I am collecting CSV data from the user and trying to move it to a SQLite database via Python. Everything works fine unless one of the values has a space in it. For example, here is part of my JavaScript object: Firstname: "Bruce" Grade: "" Lastname: "Wayne Jr" Nickname: ""  Here is the corresponding piece after applying JSON.stringify: {"Firstname":"Bruce","Lastname":"Wayne Jr","Nickname":"","Grade":""} This is then passed to Python via a form. In Python, I use: data = request.form.get("data") print(data) data2 = json.loads(data) print(data2)  I get a bunch of error messages, ending with: json.decoder.JSONDecodeError: Unterminated string starting at: line 1 column 250 (char 249) and the log of the first print gives: [{"Firstname":"Jason","Lastname":"Bourne","Nickname":"","Grade":"10"}, {"Firstname":"Steve","Lastname":"McGarret","Nickname":"5-0","Grade":""}, {"Firstname":"Danny","Lastname":"Williams","Nickname":"Dano","Grade":"12"}, {"Firstname":"Bruce","Lastname":"Wayne  So it seems to break on the space in "Wayne Jr". I used what I learned here to build the basics: https://bl.ocks.org/HarryStevens/0ce529b9b5e4ea17f8db25324423818f I believe this JavaScript function is parsing the user data: function changeDataFromField(cb){ var arr = []; $('#enter-data-field').val().replace( /\n/g, "^^^xyz" ).split( "^^^xyz" ).forEach(function(d){ arr.push(d.replace( /\t/g, "^^^xyz" ).split( "^^^xyz" )) }); cb(csvToJson(arr)); }  Updates based on comments: I am using a POST request. No AJAX. There are actually 2 inputs for the user. A text box where they can paste CSV data and a file upload option. Here is some more of the JavaScript. // Use the HTML5 File API to read the CSV function changeDataFromUpload(evt, cb){ if (!browserSupportFileUpload()) { console.error("The File APIs are not fully supported in this browser!"); } else { var data = null; var file = evt.target.files[0]; var fileName = file.name; $("#filename").html(fileName); if (file !== "") { var reader = new FileReader(); reader.onload = function(event) { var csvData = event.target.result; var parsed = Papa.parse(csvData); cb(csvToJson(parsed.data)); }; reader.onerror = function() { console.error("Unable to read " + file.fileName); }; } reader.readAsText(file); $("#update-data-from-file")[0].value = ""; } } // Method that checks that the browser supports the HTML5 File API function browserSupportFileUpload() { var isCompatible = false; if (window.File && window.FileReader && window.FileList && window.Blob) { isCompatible = true; } return isCompatible; } // Parse the CSV input into JSON function csvToJson(data) { var cols = ["Firstname","Lastname","Nickname","Grade"]; var out = []; for (var i = 0; i < data.length; i++){ var obj = {}; var row = data[i]; cols.forEach(function(col, index){ if (row[index]) { obj[col] = row[index]; } else { obj[col] = ""; } }); out.push(obj); } return out; } // Produces table for user to check appearance of data and button to complete upload function makeTable(data) { console.log(data); send_data = JSON.stringify(data); console.log(send_data); var table_data = '<table style="table-layout: fixed; width: 100%" class="table table-striped">'; table_data += '<th>First name</th><th>Last name</th><th>Nickname</th><th>Grade</th>' for(var count = 0; count < data.length; count++) { table_data += '<tr>'; table_data += '<td>'+data[count]['Firstname']+'</td>'; table_data += '<td>'+data[count]['Lastname']+'</td>'; table_data += '<td>'+data[count]['Nickname']+'</td>'; table_data += '<td>'+data[count]['Grade']+'</td>'; table_data += '</tr>'; } table_data += '</table>'; table_data += '<p><form action="/uploaded" method="post">'; table_data += 'Does the data look OK? If so, click to upload. '; table_data += '<button class="btn btn-primary" type="submit">Upload</button><p>'; table_data += '<input type="hidden" id="data" name="data" value='+send_data+'>'; table_data += '<input type="hidden" name="class_id" value="{{ class_id }}">'; table_data += '</form>'; table_data += 'Otherwise, fix the file and reload.'; document.getElementById("result_table").innerHTML = table_data; } </script> 

Answer: The problem was the way I was sending the JSON string -- it wasn't in quotes so anytime there was a space in a value, there was a problem. To fix it: I got the JSON from the answer above, then before sending the JSON string via a POST request, I enclosed it in quotes. send_data = JSON.stringify(json); send_data = "'" + send_data + "'";  I am now able to send values that have spaces in it.