title: How to change tab width when converting to JSON in Powershell
body: <p>I am creating a JSON in Powershell and I want to set a custom tab width when building it (instead of the default 4 white spaces I want to set only 2 white spaces). </p>
  
  <p>I am doing this because:</p>
  
  <ul>
  <li>the actual JSON (not the one presented in the below sample) is pretty big (100k+ rows) and if not archieved, it's size is pretty big; If I reduce the tab width the size reduction is notable.</li>
  <li>the actual JSON has a depth of 5+ nodes ! </li>
  <li>I cannot use -Compress since the JSON needs to be human readable</li>
  <li>Yes, I agree, if archived, it's size is dramatically reduced but I need it also unarchived.</li>
  </ul>
  
  <p>Sample code:</p>
  
  <pre><code>$object = New-Object PSObject
  Add-Member -InputObject $object -MemberType NoteProperty -Name Phone -Value "SomePhone"
  Add-Member -InputObject $object -MemberType NoteProperty -Name Description -Value "Lorem ipsum dolor.."
  Add-Member -InputObject $object -MemberType NoteProperty -Name Price -Value 99.99
  
  $object | ConvertTo-Json
  </code></pre>
  
  <blockquote>
    <p>Result with tab width = 4 white space characters.</p>
  </blockquote>
  
  <pre><code>{
      "Phone":  "SomePhone",
      "Description":  "Lorem ipsum dolor..",
      "Price":  99.99
  }
  </code></pre>
  
  <blockquote>
    <p>I tried compression but it doesn't give control over compression level (how agressive compression should be)</p>
  </blockquote>
  
  <pre><code>$object | ConvertTo-Json -Compress
  </code></pre>
  
  <blockquote>
    <p>Result compressed, obviously.</p>
  </blockquote>
  
  <pre><code>{"Phone":"SomePhone","Description":"Lorem ipsum dolor..","Price":99.99}
  </code></pre>
  
  <blockquote>
    <p><b>What I am trying to achieve: result with tab width = 2 white space characters.</b></p>
  </blockquote>
  
  <pre><code>{
    "Phone":  "SomePhone",
    "Description":  "Lorem ipsum dolor..",
    "Price":  99.99
  }
  </code></pre>
  
  <blockquote>
    <p>What I've tried so far is in the pseudo code below. I'm still in the loop. Please get me out of there :)</p>
  </blockquote>
  
  <pre><code>while (1) {
      Google, StackOverflow
      Try Stuff found 
      Tweak stuff found
  
      if (Correct answer) {
          break
      }
  }
  </code></pre>