---
title: "__StringToFile"
description: "JMeter __StringToFile function reference: syntax, parameters, and practical examples for parameterizing test plans with dynamic values."
url: https://docs.jmeter.ai/functions/stringtofile/
lastUpdated: 2026-10-01
source: docs.jmeter.ai
---

# __StringToFile

*Also documented in context in the [full Functions and Variables reference](/user-manual/functions/#__StringToFile).*

The `__StringToFile` function can be used to write a string to a file.
Each time it is called it writes a string to file appending or overwriting.

The default return value from the function is the empty string

| Name | Required | Description |
| --- | --- | --- |
| Path to file | Yes | Path to the file name.(The path is absolute) |
| String to write | Yes | The string to write to the file.      If you need to insert a line break in your content, use `\n` in your string. |
| Append to file? | No | The way to write the string, `true` means append, `false`     means overwrite. If not specified, the default append is `true`. |
| File encoding if not UTF-8 | No | The encoding to be used to write to the file. If not specified, the default encoding is `UTF-8`. |

## Related

- [Functions and Variables Guide](/topics/functions-and-variables/)
- [Regex Extractor Builder](/tools/regex-tester/)
- [Full Functions Reference](/user-manual/functions/)
- [Component Reference](/user-manual/component-reference/)
