{"id":353,"date":"2026-10-03T12:00:02","date_gmt":"2026-10-03T12:00:02","guid":{"rendered":"https:\/\/html-editor-online.com\/blog?p=353"},"modified":"2026-10-03T12:00:02","modified_gmt":"2026-10-03T12:00:02","slug":"why-zip-code-02134-becomes-2134-csv-to-json","status":"publish","type":"post","link":"https:\/\/html-editor-online.com\/blog\/why-zip-code-02134-becomes-2134-csv-to-json\/","title":{"rendered":"Why CSV to JSON Auto Types Loses Leading Zeros: ZIP Code 02134 to 2134"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Converting a spreadsheet of customer records from CSV to JSON should be a mechanical step, but a single settings checkbox can quietly rewrite your data. If a ZIP code column reads 02134 in the original CSV and comes out as 2134 in the JSON, nothing crashed and no error appeared. The converter still produced valid, well-formed JSON. What changed is the value&#8217;s type, and with it, its meaning: 02134 identifies a neighborhood in Boston, while 2134 alone is not a valid ZIP code. This kind of csv to json leading zeros lost auto types issue happens because the tool&#8217;s default Auto types option looks at each cell and decides, cell by cell, whether it looks like a number, a boolean, or plain text. It has no way of knowing that a ZIP code column should always stay text even when every value happens to look numeric. This article walks through the site&#8217;s documented example, compares the two settings side by side, and explains why JSON syntax validation alone cannot catch the difference.<\/p>\n\n\n\n<div class=\"wp-block-rank-math-toc-block\" id=\"rank-math-toc\"><h2>Table of Contents<\/h2><nav><ul><li class=\"\"><a href=\"#the-csv-to-json-example-that-turns-02134-into-2134-1\">The CSV to JSON Example That Turns 02134 Into 2134<\/a><\/li><li class=\"\"><a href=\"#turning-auto-types-off-keeps-every-value-a-string-2\">Turning Auto Types Off Keeps Every Value a String<\/a><\/li><li class=\"\"><a href=\"#why-a-price-and-a-zip-code-are-not-the-same-kind-of-number-3\">Why a Price and a ZIP Code Are Not the Same Kind of Number<\/a><\/li><li class=\"\"><a href=\"#how-to-check-and-fix-a-converted-file-4\">How to Check and Fix a Converted File<\/a><\/li><li class=\"\"><a href=\"#why-json-syntax-validation-cant-catch-a-lost-leading-zero-5\">Why JSON Syntax Validation Can&#039;t Catch a Lost Leading Zero<\/a><\/li><li class=\"\"><a href=\"#frequently-asked-questions\">Frequently asked questions<\/a><\/li><li class=\"\"><a href=\"#next-steps\">Next steps<\/a><\/li><li class=\"\"><a href=\"#sources\">Sources and further reading<\/a><\/li><\/ul><\/nav><\/div>\n\n\n<div class=\"wp-block-image heo-auto-image\">\n<figure data-wp-context=\"{&quot;imageId&quot;:&quot;6ac126b298d78&quot;}\" data-wp-interactive=\"core\/image\" data-wp-key=\"6ac126b298d78\" class=\"aligncenter size-large wp-lightbox-container\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"576\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on--click=\"actions.showLightbox\" data-wp-on--load=\"callbacks.setButtonStyles\" data-wp-on--pointerdown=\"actions.preloadImage\" data-wp-on--pointerenter=\"actions.preloadImageWithDelay\" data-wp-on--pointerleave=\"actions.cancelPreload\" data-wp-on-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/html-editor-online.com\/blog\/wp-content\/uploads\/2026\/09\/csv-to-json-leading-zeros-lost-auto-types-image-1-340-1-744de374c3f11156-1024x576.jpg\" alt=\"Illustration representing a CSV to JSON conversion where a ZIP code label loses a digit\" class=\"wp-image-357\" srcset=\"https:\/\/html-editor-online.com\/blog\/wp-content\/uploads\/2026\/09\/csv-to-json-leading-zeros-lost-auto-types-image-1-340-1-744de374c3f11156-1024x576.jpg 1024w, https:\/\/html-editor-online.com\/blog\/wp-content\/uploads\/2026\/09\/csv-to-json-leading-zeros-lost-auto-types-image-1-340-1-744de374c3f11156-300x169.jpg 300w, https:\/\/html-editor-online.com\/blog\/wp-content\/uploads\/2026\/09\/csv-to-json-leading-zeros-lost-auto-types-image-1-340-1-744de374c3f11156-768x432.jpg 768w, https:\/\/html-editor-online.com\/blog\/wp-content\/uploads\/2026\/09\/csv-to-json-leading-zeros-lost-auto-types-image-1-340-1-744de374c3f11156-747x420.jpg 747w, https:\/\/html-editor-online.com\/blog\/wp-content\/uploads\/2026\/09\/csv-to-json-leading-zeros-lost-auto-types-image-1-340-1-744de374c3f11156-150x84.jpg 150w, https:\/\/html-editor-online.com\/blog\/wp-content\/uploads\/2026\/09\/csv-to-json-leading-zeros-lost-auto-types-image-1-340-1-744de374c3f11156-696x392.jpg 696w, https:\/\/html-editor-online.com\/blog\/wp-content\/uploads\/2026\/09\/csv-to-json-leading-zeros-lost-auto-types-image-1-340-1-744de374c3f11156-1068x601.jpg 1068w, https:\/\/html-editor-online.com\/blog\/wp-content\/uploads\/2026\/09\/csv-to-json-leading-zeros-lost-auto-types-image-1-340-1-744de374c3f11156.jpg 1200w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><button\n\t\t\tclass=\"lightbox-trigger\"\n\t\t\ttype=\"button\"\n\t\t\taria-haspopup=\"dialog\"\n\t\t\tdata-wp-bind--aria-label=\"state.thisImage.triggerButtonAriaLabel\"\n\t\t\tdata-wp-init=\"callbacks.initTriggerButton\"\n\t\t\tdata-wp-on--click=\"actions.showLightbox\"\n\t\t\tdata-wp-style--right=\"state.thisImage.buttonRight\"\n\t\t\tdata-wp-style--top=\"state.thisImage.buttonTop\"\n\t\t>\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewBox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\" \/>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure>\n<\/div>\n\n\n<h2 class=\"wp-block-heading\" id=\"the-csv-to-json-example-that-turns-02134-into-2134-1\">The CSV to JSON Example That Turns 02134 Into 2134<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The site&#8217;s <a href=\"https:\/\/html-editor-online.com\/tools\/csv_to_json\" title=\"CSV to JSON\">CSV to JSON tool<\/a> documents a small product-catalog example that is useful for seeing exactly where a leading zero disappears. The source CSV uses this header row and one data row:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sku,name,price,in_stock,zip,notes\nA1042,Desk Lamp,39.90,true,02134,Ships Monday<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">With the tool&#8217;s default <strong>Auto types<\/strong> option turned on, converting that row produces this JSON object:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"json\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">{\n  &quot;sku&quot;: &quot;A1042&quot;,\n  &quot;name&quot;: &quot;Desk Lamp&quot;,\n  &quot;price&quot;: 39.9,\n  &quot;in_stock&quot;: true,\n  &quot;zip&quot;: 2134,\n  &quot;notes&quot;: &quot;Ships Monday&quot;\n}<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Four things happened at once. <code>sku<\/code> and <code>name<\/code> stayed strings because they contain letters. <code>price<\/code> changed from the text 39.90 to the number <code>39.9<\/code>. JSON grammar would accept 39.90 as a valid number, so the change comes from the converter turning the text into a numeric value, and a parsed number does not carry its trailing zero. <code>in_stock<\/code> changed from the text true to the actual JSON boolean <code>true<\/code>. And <code>zip<\/code> changed from 02134 to the number <code>2134<\/code>, silently dropping the leading zero because a JSON number cannot start with a zero followed by more digits. Auto types treats every numeric-looking cell the same way, whether the column holds a price, a stock flag, or an identifier. The header name zip carries no special meaning to the converter; it only reads what the cell looks like.<\/p>\n\n\n<div class=\"wp-block-image heo-auto-image\">\n<figure data-wp-context=\"{&quot;imageId&quot;:&quot;6ac126b299866&quot;}\" data-wp-interactive=\"core\/image\" data-wp-key=\"6ac126b299866\" class=\"aligncenter size-medium_large wp-lightbox-container\"><img loading=\"lazy\" decoding=\"async\" width=\"768\" height=\"432\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on--click=\"actions.showLightbox\" data-wp-on--load=\"callbacks.setButtonStyles\" data-wp-on--pointerdown=\"actions.preloadImage\" data-wp-on--pointerenter=\"actions.preloadImageWithDelay\" data-wp-on--pointerleave=\"actions.cancelPreload\" data-wp-on-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/html-editor-online.com\/blog\/wp-content\/uploads\/2026\/09\/csv-to-json-leading-zeros-lost-auto-types-image-2-340-2-b0de340ae2954997-768x432.jpg\" alt=\"Illustration of an Auto types toggle switch separating numeric values from text strings during CSV to JSON conversion\" class=\"wp-image-359\" srcset=\"https:\/\/html-editor-online.com\/blog\/wp-content\/uploads\/2026\/09\/csv-to-json-leading-zeros-lost-auto-types-image-2-340-2-b0de340ae2954997-768x432.jpg 768w, https:\/\/html-editor-online.com\/blog\/wp-content\/uploads\/2026\/09\/csv-to-json-leading-zeros-lost-auto-types-image-2-340-2-b0de340ae2954997-300x169.jpg 300w, https:\/\/html-editor-online.com\/blog\/wp-content\/uploads\/2026\/09\/csv-to-json-leading-zeros-lost-auto-types-image-2-340-2-b0de340ae2954997-1024x576.jpg 1024w, https:\/\/html-editor-online.com\/blog\/wp-content\/uploads\/2026\/09\/csv-to-json-leading-zeros-lost-auto-types-image-2-340-2-b0de340ae2954997-747x420.jpg 747w, https:\/\/html-editor-online.com\/blog\/wp-content\/uploads\/2026\/09\/csv-to-json-leading-zeros-lost-auto-types-image-2-340-2-b0de340ae2954997-150x84.jpg 150w, https:\/\/html-editor-online.com\/blog\/wp-content\/uploads\/2026\/09\/csv-to-json-leading-zeros-lost-auto-types-image-2-340-2-b0de340ae2954997-696x392.jpg 696w, https:\/\/html-editor-online.com\/blog\/wp-content\/uploads\/2026\/09\/csv-to-json-leading-zeros-lost-auto-types-image-2-340-2-b0de340ae2954997-1068x601.jpg 1068w, https:\/\/html-editor-online.com\/blog\/wp-content\/uploads\/2026\/09\/csv-to-json-leading-zeros-lost-auto-types-image-2-340-2-b0de340ae2954997.jpg 1200w\" sizes=\"auto, (max-width: 768px) 100vw, 768px\" \/><button\n\t\t\tclass=\"lightbox-trigger\"\n\t\t\ttype=\"button\"\n\t\t\taria-haspopup=\"dialog\"\n\t\t\tdata-wp-bind--aria-label=\"state.thisImage.triggerButtonAriaLabel\"\n\t\t\tdata-wp-init=\"callbacks.initTriggerButton\"\n\t\t\tdata-wp-on--click=\"actions.showLightbox\"\n\t\t\tdata-wp-style--right=\"state.thisImage.buttonRight\"\n\t\t\tdata-wp-style--top=\"state.thisImage.buttonTop\"\n\t\t>\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewBox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\" \/>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure>\n<\/div>\n\n\n<h2 class=\"wp-block-heading\" id=\"turning-auto-types-off-keeps-every-value-a-string-2\">Turning Auto Types Off Keeps Every Value a String<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The fix for the ZIP code column is the same setting that produced the problem: <strong>Auto types<\/strong>. Switching it off before reconverting the identical CSV row produces this JSON object instead:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"json\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">{\n  &quot;sku&quot;: &quot;A1042&quot;,\n  &quot;name&quot;: &quot;Desk Lamp&quot;,\n  &quot;price&quot;: &quot;39.90&quot;,\n  &quot;in_stock&quot;: &quot;true&quot;,\n  &quot;zip&quot;: &quot;02134&quot;,\n  &quot;notes&quot;: &quot;Ships Monday&quot;\n}<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Every value is now a JSON string, including <code>price<\/code> and <code>in_stock<\/code>. This is a documented rule of the converter, not a separate mode reserved for ZIP codes: with Auto types off, no cell is inspected for its content, so no cell is converted to a number, boolean, or null. That means the fix is not free. If downstream code expects <code>price<\/code> to be a JSON number so it can run arithmetic on it, or expects <code>in_stock<\/code> to be a real boolean for a conditional check, turning Auto types off breaks that code just as surely as leaving it on breaks the ZIP code. The setting applies to the whole file at once, not to a single column, so the practical answer is usually one of two paths: convert with Auto types on for files where most columns are genuine numbers or booleans and fix identifier columns by hand afterward, or convert everything with Auto types off and add explicit type conversion in your own code once the JSON is loaded.<\/p>\n\n\n<div class=\"wp-block-image heo-auto-image\">\n<figure class=\"alignleft size-medium\"><img loading=\"lazy\" decoding=\"async\" width=\"300\" height=\"169\" src=\"https:\/\/html-editor-online.com\/blog\/wp-content\/uploads\/2026\/09\/csv-to-json-leading-zeros-lost-auto-types-image-3-340-3-6e52d311fd566a3f-300x169.jpg\" alt=\"Illustration comparing a price as a quantity versus a ZIP code as an identifier in CSV to JSON conversion\" class=\"wp-image-361\" srcset=\"https:\/\/html-editor-online.com\/blog\/wp-content\/uploads\/2026\/09\/csv-to-json-leading-zeros-lost-auto-types-image-3-340-3-6e52d311fd566a3f-300x169.jpg 300w, https:\/\/html-editor-online.com\/blog\/wp-content\/uploads\/2026\/09\/csv-to-json-leading-zeros-lost-auto-types-image-3-340-3-6e52d311fd566a3f-1024x576.jpg 1024w, https:\/\/html-editor-online.com\/blog\/wp-content\/uploads\/2026\/09\/csv-to-json-leading-zeros-lost-auto-types-image-3-340-3-6e52d311fd566a3f-768x432.jpg 768w, https:\/\/html-editor-online.com\/blog\/wp-content\/uploads\/2026\/09\/csv-to-json-leading-zeros-lost-auto-types-image-3-340-3-6e52d311fd566a3f-747x420.jpg 747w, https:\/\/html-editor-online.com\/blog\/wp-content\/uploads\/2026\/09\/csv-to-json-leading-zeros-lost-auto-types-image-3-340-3-6e52d311fd566a3f-150x84.jpg 150w, https:\/\/html-editor-online.com\/blog\/wp-content\/uploads\/2026\/09\/csv-to-json-leading-zeros-lost-auto-types-image-3-340-3-6e52d311fd566a3f-696x392.jpg 696w, https:\/\/html-editor-online.com\/blog\/wp-content\/uploads\/2026\/09\/csv-to-json-leading-zeros-lost-auto-types-image-3-340-3-6e52d311fd566a3f-1068x601.jpg 1068w, https:\/\/html-editor-online.com\/blog\/wp-content\/uploads\/2026\/09\/csv-to-json-leading-zeros-lost-auto-types-image-3-340-3-6e52d311fd566a3f.jpg 1200w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/figure>\n<\/div>\n\n\n<h2 class=\"wp-block-heading\" id=\"why-a-price-and-a-zip-code-are-not-the-same-kind-of-number-3\">Why a Price and a ZIP Code Are Not the Same Kind of Number<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The reason this setting causes trouble specifically for ZIP codes, and not for prices, comes down to what each column actually represents. A price is a quantity: something you might add, multiply, or compare, and its numeric value is the point of storing it. A ZIP code, an account number, an invoice reference, or a phone number is an identifier: a label made of digits, where the exact sequence of characters, including any leading zero, is the value itself. Converting 39.90 to the number <code>39.9<\/code> loses nothing that matters, because 39.9 and 39.90 represent the same quantity. Converting 02134 to the number <code>2134<\/code> loses the leading zero, and 2134 is a different sequence of characters than 02134, even though it looks like a smaller version of the same number.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Auto types cannot make this distinction because it only ever looks at one cell&#8217;s text, never at the column header or its meaning in your data model. Something that looks like a number gets converted whether it is a price or a ZIP code. This lines up with how CSV itself works: RFC 4180 describes CSV as comma-separated text fields with an optional header row, and it does not assign any numeric type to a field just because that field&#8217;s characters happen to be digits. In the source CSV, 02134 and 39.90 are both plain text; the type guessing happens only once you convert to JSON, and it is the converter&#8217;s Auto types option, not the CSV format itself, making that decision. If you are new to how the two formats differ more broadly, the site&#8217;s <a href=\"https:\/\/html-editor-online.com\/blog\/convert-csv-to-json\/\" title=\"How to Convert CSV to JSON: The Complete Guide for Developers\">complete guide to converting CSV to JSON<\/a> covers how flat CSV rows map onto JSON&#8217;s richer set of data types.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"how-to-check-and-fix-a-converted-file-4\">How to Check and Fix a Converted File<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">When you notice a ZIP code, product code, or account number has changed after conversion, work through these steps in order:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Open the original CSV and confirm the value still has its leading zero. If the source file already says 2134 instead of 02134, no setting in the converter can recover a digit that was never there; the fix belongs upstream, in whatever exported the CSV.<\/li>\n\n\n\n<li>If the source is correct, reopen the <a href=\"https:\/\/html-editor-online.com\/tools\/csv_to_json\" title=\"CSV to JSON\">CSV to JSON tool<\/a> and turn off Auto types before converting that data again.<\/li>\n\n\n\n<li>Compare the new <code>zip<\/code> value against the original CSV character by character, not just by counting digits, since a value like 021340 would still look plausible while being wrong.<\/li>\n\n\n\n<li>Decide what the rest of your pipeline actually needs. If a script or API downstream expects <code>price<\/code> and <code>in_stock<\/code> to remain a number and a boolean, you can keep Auto types on for the whole file, but the JSON then already holds the number 2134, and no schema or consuming code can bring the zero back. In that case, edit the field by hand in the output so it reads <code>\"zip\": \"02134\"<\/code>, copying the value from the source CSV. Otherwise, convert with Auto types off and add explicit number and boolean conversion in your own code. Padding the number back to a fixed width, such as five digits, is only a guess about what the original looked like, so use it only if you know every value has that width and you have compared the results with the source.<\/li>\n\n\n\n<li>Paste the final JSON into the <a href=\"https:\/\/html-editor-online.com\/editors\/json\" title=\"JSON Editor\">JSON Editor<\/a> to check the formatting and confirm the structure reads the way you expect before you rely on it elsewhere in your project.<\/li>\n\n\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">This checklist applies to any other identifier column, not only ZIP codes. Invoice numbers, purely numeric product SKUs, and phone numbers stored without a leading plus sign all fail the same way under Auto types, for the same reason: they look numeric to the converter even though their meaning depends on every character staying exactly as written.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"why-json-syntax-validation-cant-catch-a-lost-leading-zero-5\">Why JSON Syntax Validation Can&#039;t Catch a Lost Leading Zero<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">It is tempting to assume that running the output through a JSON validator would catch this kind of mistake, but that is not what syntax validation checks. The site&#8217;s <a href=\"https:\/\/html-editor-online.com\/tools\/json_validator\" title=\"JSON Validator\">JSON Validator<\/a> uses the browser&#8217;s own <code>JSON.parse<\/code> to confirm that a document is well-formed JSON, and both versions of the ZIP field pass that check without complaint.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"json\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">{&quot;zip&quot;: 2134}\n{&quot;zip&quot;: &quot;02134&quot;}<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Both lines above are syntactically valid JSON. The first stores <code>zip<\/code> as the number 2134; the second stores it as the string 02134. <code>JSON.parse<\/code> accepts either one, because RFC 8259, the specification for JSON, only requires that a number use a valid numeral format, and both objects satisfy that requirement in their own way. The specification also explains why the leading zero disappeared in the first place: RFC 8259 permits a JSON number to start with zero only when the entire integer part is the single digit 0, so a bare number written as <code>02134<\/code> would not even be valid JSON syntax on its own. That is exactly why the converter, once it decides a cell should become a number, has to store it as <code>2134<\/code> rather than <code>02134<\/code>. There is no way to represent a numeral with a leading zero as a JSON number at all; the zero can only survive inside a string.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This is also why validation and correctness are two different checks. A JSON document can be perfectly valid and still record the wrong ZIP code, the wrong invoice number, or the wrong phone number, because validity only concerns punctuation and structure, not whether the values still mean what they meant in the source file. Catching a change like this requires comparing the converted output against the original CSV, not just running it through a parser.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"frequently-asked-questions\">Frequently asked questions<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"faq-1\">Why does Auto types change 02134 to 2134 instead of leaving it as text?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Auto types inspects each cell&#8217;s characters, not the column&#8217;s meaning. Since 02134 looks like a number, the converter stores it as the JSON number 2134. JSON numbers cannot start with a zero followed by more digits, so the leading zero cannot be kept once the value becomes a number.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"faq-2\">Will turning off Auto types fix every numeric-looking identifier column?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Yes, but it applies to the entire file, not one column. Every price, boolean, and null-looking cell also stays a string. That is fine for identifier-heavy files, but it means numeric columns you actually wanted converted will need separate handling in your own code.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"faq-3\">Can JSON store a number with a leading zero like 02134?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">No. RFC 8259 only allows a JSON number to begin with zero when the whole integer part is the single digit 0. A bare numeral written as 02134 is not valid JSON. The only way to keep that leading zero is to store the value as the string &#8220;02134&#8221;.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"faq-4\">Does the CSV to JSON tool let me keep just the ZIP column as text while converting prices to numbers?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The documented Auto types setting is a single option for the whole conversion, not a per-column control. To get mixed behavior, convert with the setting that suits most of your columns, then edit the remaining field in the JSON output directly.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"faq-5\">How can I tell if my JSON already lost a leading zero?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The JSON file itself gives no warning, since a number like 2134 is completely valid on its own. You have to compare the converted value against the original CSV row, checking the exact characters rather than just confirming the file parses correctly.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"faq-6\">Does the CSV format itself say that 02134 is a number?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">No. RFC 4180 describes CSV as comma-separated fields with an optional header row and does not assign numeric types to fields that happen to contain digits. In the source file, 02134 is just text. The type change happens only when Auto types is on during the conversion to JSON.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"faq-7\">What about price values, like 39.90 becoming 39.9 after conversion?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">That is the same Auto types behavior, but it usually does not change the value&#8217;s meaning, since 39.9 and 39.90 are the same quantity. If your output needs the exact text 39.90 for display formatting, keep that field as a string rather than relying on the converted number.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"next-steps\">Next steps<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">A ZIP code that turns from 02134 into 2134 during CSV to JSON conversion is not a bug in the converter; it is Auto types doing exactly what it is designed to do, guessing a type from a cell&#8217;s appearance rather than from the column&#8217;s meaning. The fix is straightforward once you know where to look: confirm the leading zero survives in the source CSV, turn Auto types off if the column is an identifier rather than a quantity, and compare the resulting JSON against the original file before you trust it. Neither the converter nor a JSON validator can tell you that a value&#8217;s meaning changed, only that its syntax is valid. Keeping that distinction in mind is the real lesson behind this csv to json leading zeros lost auto types example, and it applies to any column of digits that is a label rather than a number.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Related tools and resources on HTML Editor Online:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/html-editor-online.com\/tools\/csv_to_json\">CSV to JSON<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/html-editor-online.com\/tools\/json_validator\">JSON Validator<\/a><\/li>\n\n\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"sources\">Sources and further reading<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Reference\/Errors\/JSON_bad_parse\" target=\"_blank\" rel=\"noopener\">https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Reference\/Errors\/JSON_bad_parse<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Reference\/Global_Objects\/JSON\/parse\" target=\"_blank\" rel=\"noopener\">https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Reference\/Global_Objects\/JSON\/parse<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/www.rfc-editor.org\/info\/rfc8259\/\" target=\"_blank\" rel=\"noopener\">https:\/\/www.rfc-editor.org\/info\/rfc8259\/<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/datatracker.ietf.org\/doc\/html\/rfc4180\" target=\"_blank\" rel=\"noopener\">RFC 4180 &#8211; Common Format and MIME Type for Comma-Separated Values (CSV) Files<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/html-editor-online.com\/tools\/csv_to_json\">CSV to JSON &#8211; Free Online CSV to JSON Converter | HTML Editor Online<\/a><\/li>\n\n\n<\/ul>\n\n\n","protected":false},"excerpt":{"rendered":"<p>A ZIP code that reads 02134 in your CSV can silently become 2134 once you convert to JSON. Here is why the site&#8217;s CSV to JSON tool does that, how the Auto types setting controls it, and why a valid JSON file can still hide a lost leading zero.<\/p>\n","protected":false},"author":1,"featured_media":356,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[27],"tags":[78,76,52,79,53,77,80],"class_list":["post-353","post","type-post","status-publish","format-standard","has-post-thumbnail","category-json-tools","tag-auto-types","tag-csv-to-json","tag-data-conversion","tag-json-data-types","tag-json-validation","tag-leading-zeros","tag-zip-codes"],"_links":{"self":[{"href":"https:\/\/html-editor-online.com\/blog\/wp-json\/wp\/v2\/posts\/353","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/html-editor-online.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/html-editor-online.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/html-editor-online.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/html-editor-online.com\/blog\/wp-json\/wp\/v2\/comments?post=353"}],"version-history":[{"count":7,"href":"https:\/\/html-editor-online.com\/blog\/wp-json\/wp\/v2\/posts\/353\/revisions"}],"predecessor-version":[{"id":418,"href":"https:\/\/html-editor-online.com\/blog\/wp-json\/wp\/v2\/posts\/353\/revisions\/418"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/html-editor-online.com\/blog\/wp-json\/wp\/v2\/media\/356"}],"wp:attachment":[{"href":"https:\/\/html-editor-online.com\/blog\/wp-json\/wp\/v2\/media?parent=353"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/html-editor-online.com\/blog\/wp-json\/wp\/v2\/categories?post=353"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/html-editor-online.com\/blog\/wp-json\/wp\/v2\/tags?post=353"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}