diff --git a/REFERENCE.md b/REFERENCE.md
index 252bb62..5e0fbaa 100644
--- a/REFERENCE.md
+++ b/REFERENCE.md
@@ -20,6 +20,7 @@
### Functions
* [`unbound::print_config`](#unbound--print_config): Print a configuration value if it is defined and the version is supported
+* [`unbound::split_txt`](#unbound--split_txt): function to split TXT records. Long TXT records must be broken into strings of 255 characters as per RFC 4408
### Data types
@@ -2567,6 +2568,24 @@ Data type: `Optional[String[1]]`
the version when the config item was introduced
+### `unbound::split_txt`
+
+Type: Puppet Language
+
+function to split TXT records. Long TXT records must be broken into strings of 255 characters as per RFC 4408
+
+#### `unbound::split_txt(String[1] $data)`
+
+The unbound::split_txt function.
+
+Returns: `String[1]` A string of 255 character strings
+
+##### `data`
+
+Data type: `String[1]`
+
+A TXT record to split
+
## Data types
### `Unbound::Access_control`
diff --git a/functions/split_txt.pp b/functions/split_txt.pp
new file mode 100644
index 0000000..60e61f2
--- /dev/null
+++ b/functions/split_txt.pp
@@ -0,0 +1,8 @@
+# @summary function to split TXT records. Long TXT records must be broken into strings of 255 characters as per RFC 4408
+# @param data A TXT record to split
+# @return A string of 255 character strings
+function unbound::split_txt(
+ String[1] $data
+) >> String[1] {
+ $data.slice(255).map |$slice| { "\"${slice.join}\"" }.join
+}
diff --git a/spec/functions/split_txt_spec.rb b/spec/functions/split_txt_spec.rb
new file mode 100644
index 0000000..a795058
--- /dev/null
+++ b/spec/functions/split_txt_spec.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+input = "Long TXT Record #{'X' * 255}"
+output = "\"Long TXT Record #{'X' * 239}\"\"#{'X' * 16}\""
+
+describe 'unbound::split_txt' do
+ it { is_expected.to run.with_params(input).and_return(output) }
+end