The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates. | Twitter

+1 vote

I'm printing lots of lines in the console for my tests, but i need to clear the console when the game is running, Something like when i press X the console wipes every text i printed.

in Engine by (108 points)

2 Answers

+3 votes
Best answer

You can print an ANSI escape code that will clear the console this way:

func _ready():
    print("This message won't be visible.")
    print("The console was cleared.")

func clear_console():
    var escape = PoolByteArray([0x1b]).get_string_from_ascii()
    print(escape + "[2J")

Keep in mind this won't work in the editor's Output tab, as it doesn't interpret ANSI escape codes. See this Stack Overflow question for more information on clearing/resetting a console using ANSI escape codes.

by (12,878 points)
selected by
+1 vote

You mean the Console thing that the Debugger is attached to? There's a "CLEAR" button on the top right of that box, if the Output tab is selected.

by (199 points)

But can i clear that output using code? I need to be able to clear the output tab from the game.


did you ever figure out a way to clear the console from a script ?


Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.