<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Saravanapriyan</title>
    <description>The latest articles on DEV Community by Saravanapriyan (@saravanapriyanm).</description>
    <link>https://dev.to/saravanapriyanm</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F964153%2F1396cec1-ab51-4e84-92b6-3c34ee301cb6.png</url>
      <title>DEV Community: Saravanapriyan</title>
      <link>https://dev.to/saravanapriyanm</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/saravanapriyanm"/>
    <language>en</language>
    <item>
      <title>Minify GeoJSON Files: A Practical Guide</title>
      <dc:creator>Saravanapriyan</dc:creator>
      <pubDate>Wed, 12 Nov 2025 12:29:06 +0000</pubDate>
      <link>https://dev.to/saravanapriyanm/minify-geojson-files-a-practical-guide-41ml</link>
      <guid>https://dev.to/saravanapriyanm/minify-geojson-files-a-practical-guide-41ml</guid>
      <description>&lt;p&gt;As part of our visualization project (&lt;a href="https://www.datamocha.in/" rel="noopener noreferrer"&gt;Datamocha&lt;/a&gt;), we have worked with many GeoJSON files.&lt;/p&gt;

&lt;p&gt;Map files provided by clients are often in different formats and large in size.&lt;/p&gt;

&lt;p&gt;Loading a 20MB+ GeoJSON file is not feasible for web applications. At least not for showing overview visuals like:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fngvrq3asrsewuihv4nya.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fngvrq3asrsewuihv4nya.png" alt="World Population Density Map" width="800" height="432"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why not just use online tools to minify GeoJSON files?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;While online tools can be convenient, they often have limitations in terms of file size, privacy, and customization. These tools also don't support other formats like shapefiles, topojson, etc.&lt;/p&gt;

&lt;p&gt;Here are two ways that have helped us reduce GeoJSON file size by ~95%:&lt;/p&gt;

&lt;h3&gt;
  
  
  QGIS
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://www.qgis.org/" rel="noopener noreferrer"&gt;QGIS&lt;/a&gt; is an open-source, free-to-use application that handles most map file formats. It's also cross-platform.&lt;/p&gt;

&lt;p&gt;It also loads large files that web apps struggle with.&lt;/p&gt;

&lt;p&gt;Apart from minifying, we can do many things like editing shapes, merging features to form new regions, etc.&lt;/p&gt;

&lt;h4&gt;
  
  
  Steps to simplify and export GeoJSON using QGIS:
&lt;/h4&gt;

&lt;ol&gt;
&lt;li&gt;Open shape/geojson file in QGIS.&lt;/li&gt;
&lt;li&gt;Select layer in left side panel.&lt;/li&gt;
&lt;li&gt;Open &lt;code&gt;Vector &amp;gt; Geometry Tools &amp;gt; Simplify&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Provide a &lt;code&gt;Tolerance&lt;/code&gt; value.

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;0.005&lt;/code&gt; is a good starting point for zoom level 5 in Leaflet.&lt;/li&gt;
&lt;li&gt;(A bigger tolerance value means a smaller file but lower map resolution.)&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;Run&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Right-click the new layer (named &lt;code&gt;Simplified&lt;/code&gt; by default).&lt;/li&gt;
&lt;li&gt;Select &lt;code&gt;Export &amp;gt; Save Features As...&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Reduce &lt;code&gt;COORDINATE_PRECISION&lt;/code&gt; as needed (4 is good enough for zoom level 5 in Leaflet).&lt;/li&gt;
&lt;li&gt;Ensure Encoding = UTF-8 and CRS = EPSG:4326 - WGS 84.&lt;/li&gt;
&lt;li&gt;Provide a file name and folder location.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Using this method, we have reduced the GeoJSON file size from 24MB to 1.2MB. &lt;/p&gt;

&lt;p&gt;Still the file contains white spaces and long property keys. We use the following tool to minify it further.&lt;/p&gt;

&lt;h3&gt;
  
  
  minify-geojson
&lt;/h3&gt;

&lt;p&gt;Use the following CLI tool to further reduce file size:&lt;br&gt;
&lt;a href="https://github.com/TNOCS/minify-geojson" rel="noopener noreferrer"&gt;https://github.com/TNOCS/minify-geojson&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Examples:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Shrink property keys and output to original.min.geojson&lt;/span&gt;
npx minify-geojson &lt;span class="nt"&gt;-k&lt;/span&gt; original.geojson

&lt;span class="c"&gt;# Remove blacklisted properties&lt;/span&gt;
minify-geojson &lt;span class="nt"&gt;-b&lt;/span&gt; &lt;span class="s2"&gt;"property1, property2"&lt;/span&gt; original.geojson

&lt;span class="c"&gt;# Keep only whitelisted properties&lt;/span&gt;
minify-geojson &lt;span class="nt"&gt;-w&lt;/span&gt; &lt;span class="s2"&gt;"property1, property2"&lt;/span&gt; original.geojson

&lt;span class="c"&gt;# Remove superfluous decimals (keep first 5)&lt;/span&gt;
minify-geojson &lt;span class="nt"&gt;-c&lt;/span&gt; 5 original.geojson
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After using this tool, we were able to reduce the 1.2MB file further to ~1MB. Not as much as the previous step, but every bit helps when it comes to web performance.&lt;/p&gt;

&lt;p&gt;~ That's it folks ~&lt;/p&gt;

&lt;p&gt;Thanks to QGIS Contributors and TNOCS for these awesome tools!&lt;/p&gt;

&lt;p&gt;Cover Image by &lt;a href="https://pixabay.com/users/yuri_b-2216431/?utm_source=link-attribution&amp;amp;utm_medium=referral&amp;amp;utm_campaign=image&amp;amp;utm_content=2401458" rel="noopener noreferrer"&gt;Yuri&lt;/a&gt; from &lt;a href="https://pixabay.com//?utm_source=link-attribution&amp;amp;utm_medium=referral&amp;amp;utm_campaign=image&amp;amp;utm_content=2401458" rel="noopener noreferrer"&gt;Pixabay&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Map By &lt;a href="//commons.wikimedia.org/w/index.php?title=User:English_English_is_Correct&amp;amp;action=edit&amp;amp;redlink=1" title="User:English English is Correct (page does not exist)"&gt;English English is Correct&lt;/a&gt; - &lt;span&gt;Own work&lt;/span&gt;, &lt;a href="http://creativecommons.org/publicdomain/zero/1.0/deed.en" title="Creative Commons Zero, Public Domain Dedication" rel="noopener noreferrer"&gt;CC0&lt;/a&gt;, &lt;a href="https://commons.wikimedia.org/w/index.php?curid=145129274" rel="noopener noreferrer"&gt;Link&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>resources</category>
    </item>
  </channel>
</rss>
