# Can you clear the System Console without restarting Blender?

The question is simple enough, but I can't find the answer. Is there an operator or something similar that clears the Blender System Console history? I would also be willing to create an operator type script to "purge" the console. It would be interesting to see if it's possible, or I'm just "delirious". Restarting blender doesn't take long, but it would be nice to have a "Button" to do this.

• Try printing a '\f' form feed and see what that does? – Ron Jensen Aug 7 at 23:07
• Forgive my ignorance, what should I enter? print ("\ f")? – Noob Cat Aug 7 at 23:13
• Do print('\f') with no space. Its a control character like '\n' for newline – Ron Jensen Aug 7 at 23:28
• Ok I tried it from a Blender Text script and from Blender's python console. Weird symbols come up, but I don't really understand what this is for. – Noob Cat Aug 7 at 23:30
• Just like \n \t and other text control stuff, where \f stand for form feed to indicate output go on next page. Which is not clear console for sure – HikariTW Aug 7 at 23:37

Below is an example add-on that adds a button to the text editor for this purpose. Clearing the console is done with the platform specific commands cls for Windows and clear for Linux and macOS. Both are executed through os.system(command)

bl_info = {
"name": "Clear System Console",
"author": "Robert Guetzkow",
"version": (1, 0, 0),
"blender": (2, 81, 0),
"description": "Clear the system console.",
"wiki_url": "",
"category": "Text Editor"}

import bpy
import os

class CLEARCONSOLE_OT_clear(bpy.types.Operator):
bl_idname = "clearconsole.clear"
bl_label = "Clear System Console"
bl_description = "This operator clears the system console."
bl_options = {"REGISTER"}

def execute(self, context):
if os.name == "nt":
os.system("cls")
else:
os.system("clear")
return {"FINISHED"}

def draw(self, context):
self.layout.operator(CLEARCONSOLE_OT_clear.bl_idname)

classes = (CLEARCONSOLE_OT_clear,)

def register():
for cls in classes:
bpy.utils.register_class(cls)

def unregister():

for cls in classes:
bpy.utils.unregister_class(cls)

if __name__ == "__main__":
register()

• I hadn't thought of other operating systems, as I use it on Windows, and I wanted to create a tools that simplifies my programming life a little. All clear, this answer did what I was looking for and more – Noob Cat Aug 7 at 23:59

You can use os.system and call cls or clear:

• os.system('cls')
• os.system('clear')

sort of snippet:

from os import system
cls = lambda: system('cls')

cls() #this function call will clear the console

• Very clear and simple, it works wonders – Noob Cat Aug 7 at 23:49
• Sorry, didn't see your answer until I was done implementing mine. – Robert Gützkow Aug 8 at 0:14
• @RobertGützkow That's a nice spinet which should be archived at north pole! – HikariTW Aug 8 at 0:20