diff --git a/cmd/evm/runner.go b/cmd/evm/runner.go
index 3e8ecf6c3c5c685c90d6922a936c6523e91adc0e..3cbdcad017117ac02f0dd700cee386e1f65c3ee3 100644
--- a/cmd/evm/runner.go
+++ b/cmd/evm/runner.go
@@ -17,6 +17,7 @@
 package main
 
 import (
+	"bytes"
 	"encoding/json"
 	"fmt"
 	"io/ioutil"
@@ -145,6 +146,7 @@ func runCmd(ctx *cli.Context) error {
 		} else {
 			hexcode = []byte(codeFlag)
 		}
+		hexcode = bytes.TrimSpace(hexcode)
 		if len(hexcode)%2 != 0 {
 			fmt.Printf("Invalid input length for hex data (%d)\n", len(hexcode))
 			os.Exit(1)