diff --git a/sys/fmt/fmt.c b/sys/fmt/fmt.c
index e75c7487a34d36c1a27879e7dc19f944a0f0ff23..5ea21e8b8e9a705a766cc6d15d5c2b2c3d7e9e86 100644
--- a/sys/fmt/fmt.c
+++ b/sys/fmt/fmt.c
@@ -83,6 +83,15 @@ size_t fmt_strlen(const char *str)
     return (tmp - str);
 }
 
+size_t fmt_strnlen(const char *str, size_t maxlen)
+{
+    const char *tmp = str;
+    while(*tmp && maxlen--) {
+        tmp++;
+    }
+    return (tmp - str);
+}
+
 size_t fmt_str(char *out, const char *str)
 {
     int len = 0;
diff --git a/sys/include/fmt.h b/sys/include/fmt.h
index d88608b2c9266593fbddb0236c781b725ee14d04..229f9396112267c227f70598b9f1e3478d1476e9 100644
--- a/sys/include/fmt.h
+++ b/sys/include/fmt.h
@@ -294,6 +294,17 @@ size_t fmt_float(char *out, float f, unsigned precision);
  */
 size_t fmt_strlen(const char *str);
 
+/**
+ * @brief Count at most @p maxlen characters until '\0' (exclusive) in @p str
+ *
+ * @param[in]   str     Pointer to string
+ * @param[in]   maxlen  Maximum number of chars to count
+ *
+ * @return      nr of characters in string @p str points to, or @p maxlen if no
+ *              null terminator is found within @p maxlen chars
+ */
+size_t fmt_strnlen(const char *str, size_t maxlen);
+
 /**
  * @brief Copy null-terminated string (excluding terminating \0)
  *