diff --git a/classlib/src/main/java/org/teavm/classlib/impl/console/JSStdoutPrintStream.java b/classlib/src/main/java/org/teavm/classlib/impl/console/JSStdoutPrintStream.java
index 76f2de9eb..9e3b99627 100644
--- a/classlib/src/main/java/org/teavm/classlib/impl/console/JSStdoutPrintStream.java
+++ b/classlib/src/main/java/org/teavm/classlib/impl/console/JSStdoutPrintStream.java
@@ -22,6 +22,9 @@ import org.teavm.jso.JSBody;
 public class JSStdoutPrintStream extends JsConsolePrintStream {
     @Override
     public void print(String s) {
+        if (s == null) {
+            s = "null";
+        }
         if (PlatformDetector.isWebAssemblyGC()) {
             for (int i = 0; i < s.length(); ++i) {
                 WasmGCSupport.putCharStdout(s.charAt(i));