ComfyUI Node: center

Class Name

Basic data handling: StringCenter

Category
Basic/STRING
Author
StableLlama (Account age: 861days)
Extension
Basic data handling
Latest Updated
2026-05-07
Github Stars
0.04K

How to Install Basic data handling

Install this extension via the ComfyUI Manager by searching for Basic data handling
  • 1. Click the Manager button in the main menu
  • 2. Select Custom Nodes Manager button
  • 3. Enter Basic data handling in the search bar
After installation, click the Restart button to restart ComfyUI. Then, manually refresh your browser to clear the cache and access the updated list of nodes.

Visit ComfyUI Online for ready-to-use ComfyUI environment

  • Free trial available
  • 16GB VRAM to 80GB VRAM GPU machines
  • 400+ preloaded models/nodes
  • Freedom to upload custom models/nodes
  • 200+ ready-to-run workflows
  • 100% private workspace with up to 200GB storage
  • Dedicated Support

Run ComfyUI Online

center Description

StringCenter centers a string within a specified width using customizable padding characters.

center:

The StringCenter node is designed to center a given string within a specified width, providing a visually balanced appearance by padding the string with a chosen character. This node is particularly useful when you need to format text for display purposes, ensuring that it appears neatly aligned within a designated space. By default, spaces are used for padding, but you can customize this by selecting any single character to fill the extra space. This flexibility allows you to tailor the appearance of your text to suit various aesthetic or formatting requirements, making it a versatile tool for text manipulation in your projects.

center Input Parameters:

string

This parameter represents the text that you want to center. It is the main content that will be adjusted to fit within the specified width. The default value is an empty string, which means if no text is provided, the output will simply be a string of padding characters.

width

The width parameter defines the total length of the output string, including the original text and any padding. It determines how much space the centered text will occupy. The default value is 20, with a minimum of 0 and a maximum of 1000. If the specified width is less than the length of the input string, the string will remain unchanged.

fillchar

This optional parameter specifies the character used to fill the space around the centered text. By default, a space character is used. If a string longer than one character is provided, only the first character will be used for padding. If an empty string is given, it defaults to a space.

center Output Parameters:

string

The output is a single string that contains the original text centered within the specified width, padded with the chosen fill character. This output is useful for creating visually appealing text layouts, ensuring that your text is evenly distributed within a given space.

center Usage Tips:

  • Use the width parameter to control the total length of the output string, ensuring it fits within your desired layout or design.
  • Customize the fillchar to match the theme or style of your project, such as using asterisks or dashes for decorative purposes.
  • Remember that if the width is smaller than the length of the input string, the string will not be altered, so choose a width that accommodates your text.

center Common Errors and Solutions:

Invalid fill character length

  • Explanation: The fillchar parameter should be a single character. If a longer string is provided, only the first character will be used.
  • Solution: Ensure that the fillchar is a single character to avoid unexpected results.

Width less than string length

  • Explanation: If the width is set to a value smaller than the length of the input string, the string will not be centered and will remain unchanged.
  • Solution: Set the width to a value greater than or equal to the length of the input string to achieve the desired centering effect.

center Related Nodes

Go back to the extension to check out more related nodes.
Basic data handling
RunComfy
Copyright 2025 RunComfy. All Rights Reserved.

RunComfy is the premier ComfyUI platform, offering ComfyUI online environment and services, along with ComfyUI workflows featuring stunning visuals. RunComfy also provides AI Models, enabling artists to harness the latest AI tools to create incredible art.