# How to create an automatic cast/conversion node for custom data types using blueprint libraries in c++

**URL:** <https://forums.unrealengine.com/t/how-to-create-an-automatic-cast-conversion-node-for-custom-data-types-using-blueprint-libraries-in-c/775380>\
**Category:** Tutorial & Course Discussions\
**Tags:** tutorial, unreal-engine, CPP, Blueprint\
**Created:** [February 21, 2023, 9:23am UTC](https://forums.unrealengine.com/t/how-to-create-an-automatic-cast-conversion-node-for-custom-data-types-using-blueprint-libraries-in-c/775380 "2023-02-21T09:23:22Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gisli](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/gisli/32/938382_2.png) [@Gisli](https://forums.unrealengine.com/u/Gisli)\
**Post date:** [February 21, 2023, 9:23am UTC](https://forums.unrealengine.com/t/how-to-create-an-automatic-cast-conversion-node-for-custom-data-types-using-blueprint-libraries-in-c/775380/1 "2023-02-21T09:23:22Z")

</div>

Hi everyone!

I’ve always been a huge fan of writing clean blueprint code (and making c++ code that enables that. I just figured out how to create functions that can automatically convert a custom data type (struct) into some other data format.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/3/e/03ee795f6b92d0e16c284b3f5a32743ba79a90c2.png)

Here is how it works:

**You make your custom struct with some data**

```auto
USTRUCT(BlueprintType)
struct FMyPrintableStruct
{
	GENERATED_BODY()

	UPROPERTY(BlueprintReadOnly)
	int32 FirstValue;

	UPROPERTY(BlueprintReadOnly)
	FString MyStringThatILike;
};

```

**Then you create the blueprint function library with the conversion code**

```auto
//.h
UCLASS()
class UMyAwesomeFunctionLibrary : public UBlueprintFunctionLibrary
{
	GENERATED_BODY()

public:
	UFUNCTION(BlueprintPure,meta = (DisplayName = "Convert To String",CompactNodeTitle = "->",BlueprintAutocast),Category = MyPrintableStruct)
	static FString Conv_MyPrintableStructToString(MyPrintableStruct);
};

//.cpp
FString UMyAwesomeFunctionLibrary::Conv_MyPrintableStuctToString(MyCustomStruct Struct)
{
	return Struct.MyStringThatILike + " - " + FString::FromInt(Struct.FirstValue);
}

```

And that’s it!

Here is a tutorial to show how I did it

[![](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/a/c/1ac050570c606a8a86218f31f75d96fb91e8869b.jpeg "Unreal Engine Tutorial - How to convert a struct to another data type in c++ and blueprints") ](https://www.youtube.com/watch?v=U2ONtaFvogI)

---

<div class="post-metadata">

**Author:** ![Kinali\_JasonC](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Kinali\_JasonC](https://forums.unrealengine.com/u/Kinali_JasonC)\
**Post date:** [April 23, 2026, 7:52pm UTC](https://forums.unrealengine.com/t/how-to-create-an-automatic-cast-conversion-node-for-custom-data-types-using-blueprint-libraries-in-c/775380/2 "2026-04-23T19:52:23Z")

</div>

Thanks for posting this!

Just wanted to add a quick thing: The conversion node has to be **declared in a BlueprintFunctionLibrary**.

Static blueprint conversion functions in other classes (Subsystem, UObject, etc.) will still work but won’t automatically convert when connecting nodes, it’ll prompt you with a drop down menu instead.
