Apple - Adjust width of spacer between Mac OS dock icons
I just tried typing in different things and discovered that "small-spacer-tile" adds a narrow space.
defaults write com.apple.dock persistent-apps -array-add '{"tile-type"="small-spacer-tile";}'
killall Dock
Here, a "small-spacer-tile" vs a "spacer-tile":
I held the same belief, that the spaces were too big. I've researched this rather extensively, and found no way to lessen the gap.
I went in another direction - adding a vertical line instead of a space.
To do this, I created an app in Automator that simply launches the Finder. I called them line1.app and line2.app (for however many lines you want, you need to create a different app).
If you've never used Automator, here is a simple way to create the apps I mentioned.
Using Automator to Create an App
Open Automator.
Select "New Document" in the lower left.
Choose a type for your document - Application.
Find "Launch Application" from the list, and drag it into the workspace on the right.
Select the Finder app. To do this, you have to go down to "New Variable." It will tell you to select the path. Click the dropdown, and go down to "Other." Do a search for "Finder.app" and select it. Then click "Done."
Click "Run" in the upper right hand corner, just to make sure it launches the Finder.
Go to File > Export...
Name the file and choose a location for it. I picked my Applications folder. Click Save.
Repeat steps 7 & 8 for as many lines you want, changing the name each time. I kept the names numerical for ease of use. line1.app, line2.app, etc.
Changing the Icon to a Vertical Line
Find or create a vertical line to use. The color of the vertical line separating your folders and apps on the dock is #5d5d64. I just created one from scratch using Photoshop.
Open the line-graphic in Preview. (Locate it in the Finder, and double-click on it.) Go to Edit > Select All > Copy.
Locate your apps in the Finder. Right-click on the app, select "Get Info." The icon will be in the upper right. Click on it. The do COMMAND⌘ + V to Paste. Close the "Get Info" window. (You may need to close the Finder and re-open it to see the new icon.)
Locate your apps in the Finder. Drag them into the Dock.
I like the look of the lines, and if I click on them, they just launch the Finder now.