diff --git a/reanimate-svg.cabal b/reanimate-svg.cabal
--- a/reanimate-svg.cabal
+++ b/reanimate-svg.cabal
@@ -1,5 +1,5 @@
 name:                reanimate-svg
-version:             0.9.1.0
+version:             0.9.1.1
 synopsis:            SVG file loader and serializer
 description:
   reanimate-svg provides types representing a SVG document,
@@ -40,6 +40,7 @@
   other-modules: Graphics.SvgTree.XmlParser
                , Graphics.SvgTree.CssParser
                , Graphics.SvgTree.ColorParser
+               , Graphics.SvgTree.Misc
 
   if impl(ghc >= 8.0)
     ghc-options: -Wcompat -Wnoncanonical-monad-instances -Wnoncanonical-monadfail-instances
diff --git a/src/Graphics/SvgTree/CssTypes.hs b/src/Graphics/SvgTree/CssTypes.hs
--- a/src/Graphics/SvgTree/CssTypes.hs
+++ b/src/Graphics/SvgTree/CssTypes.hs
@@ -29,10 +29,11 @@
 import qualified Data.Text              as T
 import qualified Data.Text.Lazy.Builder as TB
 import           Text.Printf
-import           Data.Ratio
 
 import           Codec.Picture          (PixelRGBA8 (..))
 
+import           Graphics.SvgTree.Misc
+
 -- | Alias describing a "dot per inch" information
 -- used for size calculation (see toUserUnit).
 type Dpi = Int
@@ -214,21 +215,15 @@
 -- CSS or a svg attributes.
 serializeNumber :: Number -> String
 serializeNumber n = case n of
-    Num c     -> ppDouble c
-    Px c      -> printf "%.*gpx" precision c
-    Em cc     -> printf "%.*gem" precision cc
+    Num c     -> ppD c
+    Px c      -> printf "%spx" (ppD c)
+    Em cc     -> printf "%sem" (ppD cc)
     Percent p -> printf "%d%%" (floor $ 100 * p :: Int)
-    Pc p      -> printf "%.*gpc" precision p
-    Mm m      -> printf "%.*gmm" precision m
-    Cm c      -> printf "%.*gcm" precision c
-    Point p   -> printf "%.*gpt" precision p
-    Inches i  -> printf "%.*gin" precision i
-  where
-    ppDouble d = pickMin
-      (printf "%.*g" precision d)
-      (printf "%g" d)
-    pickMin a b = if length a < length b then a else b
-    precision = 6 :: Int
+    Pc p      -> printf "%spc" (ppD p)
+    Mm m      -> printf "%smm" (ppD m)
+    Cm c      -> printf "%scm" (ppD c)
+    Point p   -> printf "%spt" (ppD p)
+    Inches i  -> printf "%sin" (ppD i)
 
 instance TextBuildable Number where
    tserialize = TB.fromText . T.pack . serializeNumber
diff --git a/src/Graphics/SvgTree/Misc.hs b/src/Graphics/SvgTree/Misc.hs
new file mode 100644
--- /dev/null
+++ b/src/Graphics/SvgTree/Misc.hs
@@ -0,0 +1,19 @@
+module Graphics.SvgTree.Misc where
+
+import Numeric
+
+ppD :: Double -> String
+ppD c = pickMin (showFFloat Nothing c "") (showFFloat (Just precision) c "")
+  where
+    pickMin [] _ = []
+    pickMin _ [] = []
+    pickMin (x:xs) (_:ys) = x : pickMin xs ys
+    precision = 6
+
+ppF :: Float -> String
+ppF c = pickMin (showFFloat Nothing c "") (showFFloat (Just precision) c "")
+  where
+    pickMin [] _ = []
+    pickMin _ [] = []
+    pickMin (x:xs) (_:ys) = x : pickMin xs ys
+    precision = 6
diff --git a/src/Graphics/SvgTree/PathParser.hs b/src/Graphics/SvgTree/PathParser.hs
--- a/src/Graphics/SvgTree/PathParser.hs
+++ b/src/Graphics/SvgTree/PathParser.hs
@@ -26,10 +26,10 @@
 import           Data.Scientific            (toRealFloat)
 
 import Numeric
-import Text.Show
 import Data.List
 import qualified Data.Text                  as T
 import           Graphics.SvgTree.Types
+import           Graphics.SvgTree.Misc
 import           Linear                     hiding (angle, point)
 import           Text.Printf                (printf)
 
@@ -52,7 +52,7 @@
     iParse = num <* skipSpace
 
 serializeViewBox :: (Double, Double, Double, Double) -> String
-serializeViewBox (a, b, c, d) = printf "%g %g %g %g" a b c d
+serializeViewBox (a, b, c, d) = printf "%s %s %s %s" (ppD a) (ppD b) (ppD c) (ppD d)
 
 commaWsp :: Parser ()
 commaWsp = skipSpace *> option () (string "," *> return ()) <* skipSpace
@@ -157,14 +157,15 @@
   EndPath -> showChar 'Z'
   where
     serializeArg (a, b, c, d, e, V2 x y) =
-        showFFloat Nothing a . showChar ' ' .
-        showFFloat Nothing b . showChar ' ' .
-        showFFloat Nothing c . showChar ' ' .
-        shows (fromEnum d) . showChar ' ' .
-        shows (fromEnum e) . showChar ' ' .
-        showFFloat Nothing x . showChar ',' .
-        showFFloat Nothing y
-        -- printf "%g %g %g %d %d %g,%g" a b c (fromEnum d) (fromEnum e) x y
+        -- ppD a . showChar ' ' .
+        -- ppD b . showChar ' ' .
+        -- ppD c . showChar ' ' .
+        -- shows (fromEnum d) . showChar ' ' .
+        -- shows (fromEnum e) . showChar ' ' .
+        -- ppD x . showChar ',' .
+        -- ppd y
+        printf "%s %s %s %d %d %s,%s"
+          (ppD a) (ppD b) (ppD c) (fromEnum d) (fromEnum e) (ppD x) (ppD y)
     serializeArgs = unwordsS . fmap serializeArg
 
 
diff --git a/src/Graphics/SvgTree/Types.hs b/src/Graphics/SvgTree/Types.hs
--- a/src/Graphics/SvgTree/Types.hs
+++ b/src/Graphics/SvgTree/Types.hs
@@ -221,6 +221,7 @@
 import           Data.Semigroup            (Semigroup (..))
 import qualified Data.Text                 as T
 import           Graphics.SvgTree.CssTypes
+import           Graphics.SvgTree.Misc
 import           Linear                    hiding (angle)
 
 import           Text.Printf
@@ -399,14 +400,16 @@
 serializeTransformation t = case t of
   TransformUnknown -> ""
   TransformMatrix a b c d e f ->
-      printf "matrix(%g, %g, %g, %g, %g, %g)" a b c d e f
-  Translate x y -> printf "translate(%g, %g)" x y
-  Scale x Nothing -> printf "scale(%g)" x
-  Scale x (Just y) -> printf "scale(%g, %g)" x y
-  Rotate angle Nothing -> printf "rotate(%g)" angle
-  Rotate angle (Just (x, y))-> printf "rotate(%g, %g, %g)" angle x y
-  SkewX x -> printf "skewX(%g)" x
-  SkewY y -> printf "skewY(%g)" y
+      printf "matrix(%s, %s, %s, %s, %s, %s)"
+        (ppD a) (ppD b) (ppD c) (ppD d) (ppD e) (ppD f)
+  Translate x y -> printf "translate(%s, %s)" (ppD x) (ppD y)
+  Scale x Nothing -> printf "scale(%s)" (ppD x)
+  Scale x (Just y) -> printf "scale(%s, %s)" (ppD x) (ppD y)
+  Rotate angle Nothing -> printf "rotate(%s)" (ppD angle)
+  Rotate angle (Just (x, y))-> printf "rotate(%s, %s, %s)"
+    (ppD angle) (ppD x) (ppD y)
+  SkewX x -> printf "skewX(%s)" (ppD x)
+  SkewY y -> printf "skewY(%s)" (ppD y)
 
 -- | Transform a list of transformations to a string for svg
 -- `transform` attributes.
diff --git a/src/Graphics/SvgTree/XmlParser.hs b/src/Graphics/SvgTree/XmlParser.hs
--- a/src/Graphics/SvgTree/XmlParser.hs
+++ b/src/Graphics/SvgTree/XmlParser.hs
@@ -46,6 +46,7 @@
                                                CssElement (..))
 import           Graphics.SvgTree.PathParser
 import           Graphics.SvgTree.Types
+import           Graphics.SvgTree.Misc
 import qualified Text.XML.Light               as X
 import           Text.XML.Light.Proc          (elChildren, findAttrBy)
 
@@ -111,7 +112,7 @@
 
 instance ParseableAttribute Double where
   aparse = parseMayStartDot num
-  aserialize v = Just $ printf "%g" v
+  aserialize v = Just $ printf "%s" (ppD v)
 
 instance ParseableAttribute Texture where
   aparse = parse textureParser
@@ -492,7 +493,7 @@
 opacitySetter attribute elLens =
     SvgAttributeLens attribute updater serializer
   where
-    serializer a = printf "%g" <$> a ^. elLens
+    serializer a = printf "%s" . ppF <$> a ^. elLens
     updater el str = case parseMayStartDot num str of
         Nothing -> el
         Just v  -> el & elLens .~ Just (realToFrac v)
@@ -982,7 +983,7 @@
 
       rotateNotEmpty [] = Nothing
       rotateNotEmpty lst =
-          Just . unwords $ printf "%g" <$> lst
+          Just . unwords $ printf "%s" . ppD <$> lst
 
 
 instance XMLUpdatable TextPath where
