Let $$p(\cdot ):\ \mathbb R^n\rightarrow (0,\infty )$$ p ( · ) : R n → ( 0 , ∞ ) be a variable exponent function satisfying that there exists a constant $$p_0\in (0,p_-)$$ p 0 ∈ ( 0 , p - ) , where $$p_-:=\hbox {ess inf}_{x\in \mathbb R^n}p(x)$$ p - : = ess inf x ∈ R n p ( x ) , such that the Hardy–Littlewood maximal operator is bounded on the variable exponent Lebesgue space $$L^{p(\cdot )/p_0}(\mathbb R^n)$$ L p ( · ) / p 0 ( R n ) . In this article, via investigating relations between boundary values of harmonic functions on the upper half space and elements of variable exponent Hardy spaces $$H^{p(\cdot )}(\mathbb R^n)$$ H p ( · ) ( R n ) introduced by E. Nakai and Y. Sawano and, independently, by D. Cruz-Uribe and L.-A. D. Wang, the authors characterize $$H^{p(\cdot )}(\mathbb R^n)$$ H p ( · ) ( R n ) via the first order Riesz transforms when $$p_-\in (\frac{n-1}{n},\infty )$$ p - ∈ ( n - 1 n , ∞ ) , and via compositions of all the first order Riesz transforms when $$p_-\in (0,\frac{n-1}{n})$$ p - ∈ ( 0 , n - 1 n ) .